1

I am trying to use AUnit for Unit testing in apama. So I checked and read tha Aunit package uses Apama Pysys in the backend to test Apama application.

While I was successful in building the Aunit package , I am getting an error in testing the sample Apama monitors given with it. I am continuously getting the Warning:

c:\aunit-master\bin>aunit test Math

Copying C:\aunit-master\workspace\Math/src/Float.mon to C:\aunit-master\.__test\resources\Float.mon

2019-02-26 13:18:30,296 INFO  ==============================================================
2019-02-26 13:18:30,300 INFO  Id   : MathFloatTest
2019-02-26 13:18:30,302 INFO  Title: MathFloatTest
2019-02-26 13:18:30,304 INFO  ==============================================================
2019-02-26 13:18:33,068 WARN  caught <class '_csv.Error'> while running test: iterator should return strings, not bytes (did you open the file in text mode?)
Traceback (most recent call last):
  File "C:\SoftwareAG2\Apama\third_party\python\Lib\site-packages\pysys\baserunner.py", line 561, in __call__
    self.testObj.validate()
  File "C:\aunit-master\.__test\MathFloatTest\run.py", line 27, in validate
    for row in reader:
_csv.Error: iterator should return strings, not bytes (did you open the file in text mode?)
2019-02-26 13:18:33,299 WARN  iterator should return strings, not bytes (did you open the file in text mode?) (<class '_csv.Error'>) ... blocked
2019-02-26 13:18:36,196 WARN  caught <class '_csv.Error'> while running test: iterator should return strings, not bytes (did you open the file in text mode?)
Traceback (most recent call last):
  File "C:\SoftwareAG2\Apama\third_party\python\Lib\site-packages\pysys\baserunner.py", line 561, in __call__
    self.testObj.validate()
  File "C:\aunit-master\.__test\MathIntegerTest\run.py", line 27, in validate
    for row in reader:
_csv.Error: iterator should return strings, not bytes (did you open the file in text mode?)
2019-02-26 13:18:36,203 WARN  iterator should return strings, not bytes (did you open the file in text mode?) (<class '_csv.Error'>) ... blocked
2019-02-26 13:18:36,328 CRIT
2019-02-26 13:18:36,329 CRIT  Completed test run at:  Tuesday 2019-02-26 13:18:36 W. Europe Standard Time
2019-02-26 13:18:36,330 CRIT  Total test duration:    6.04 secs
2019-02-26 13:18:36,330 CRIT
2019-02-26 13:18:36,331 CRIT  Summary of non passes:
2019-02-26 13:18:36,331 CRIT    BLOCKED: MathFloatTest
2019-02-26 13:18:36,332 CRIT    BLOCKED: MathIntegerTest

And this warning gives the results of the testcase as BLOCKED.

Saurav Sahu
  • 13,038
  • 6
  • 64
  • 79
  • 1
    Post your errors in code form, do not use images, see [this thread](https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors) for reasoning standing behind it. – Szymon Maszke Feb 27 '19 at 12:32
  • Further to what Szymon said, please give more detail on what you tried to do to investigate the error See https://stackoverflow.com/help/how-to-ask for some guidelines on asking questions. – Caribou Feb 27 '19 at 12:35
  • Possible duplicate of [csv.Error: iterator should return strings, not bytes](https://stackoverflow.com/questions/8515053/csv-error-iterator-should-return-strings-not-bytes) – Caribou Feb 27 '19 at 13:20

3 Answers3

3

The error seems to be from line 27 of https://github.com/antoinewaugh/aunit/blob/master/test-build/template/run_fast.py.template and looks like a python 2 vs 3 compatibility thing. So the quickest way to get this working for you might be to try running it with Python 2 (if Antoine hasn’t yet added support for Python 3 in AUnit)?

Or for a more long-term approach maybe try Caribou's fix to AUnit and if it works submit a pull request to get it incorproated?

Ben Spiller
  • 477
  • 4
  • 12
1

Without any code to look at and understand what you are doing, it looks to me like either the file being read (the csv) is in an unexpected encoding.

If you are opening the file at some point you need to make sure that it is read with the correct encoding or opened as a text file (I used utf8 below but if that doesn't work you may need to work out what encoding it is.

csvfile  = open('my.csv', "rt", encoding='utf8')

If you are not opening the file, and the open is happening within the library, then it could still be a bad encoding of what is being read - perhaps the data should be utf8 but it's some windows format?

you'll need to add code to the question so we can examine what is going on properly however if neither of these solves the issue.

Caribou
  • 2,070
  • 13
  • 29
  • The file i am trying to test is provided as a sample with AUnit package. The file opening is done by the script iteself i did not change anything in it. I updated the code block in my question just to show in detail what command i executed and the response i get. – Balpreet Singh Feb 27 '19 at 13:50
  • Then I suspect you'll need to talk to the auther of the repo on github... – Caribou Feb 27 '19 at 14:02
1

Aunit has been patched to support both versions of python (2 & 3).

Thanks for raising the issue.

Pull requests on the project are also welcome.

Antoine
  • 11
  • 1