Aunit test returning blocked for given Sample Apama Projects

75 views Asked by At

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.

3

There are 3 answers

2
Caribou On

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.

1
Ben Spiller On

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?

0
Antoine On

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.