我正尝试在apama中使用AUnit进行单元测试。所以我检查并阅读了Aunit包在后端使用Apama Pysys来测试Apama应用程序。
虽然我成功地构建了Aunit包,但在测试随其提供的示例Apama监视器时却遇到了错误。我不断收到警告:
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此警告将测试用例的结果显示为阻塞。
发布于 2019-02-28 00:58:59
这个错误似乎来自https://github.com/antoinewaugh/aunit/blob/master/test-build/template/run的第27行,看起来像是python 2与3的兼容性问题。因此,让它为您工作的最快方法可能是尝试用Python2运行它(如果Antoine还没有在AUnit中添加对Python3的支持)?
或者,对于更长期的方法,也许可以尝试Caribou对AUnit的修复,如果它有效,则提交一个拉请求来将其解除关联?
发布于 2019-02-27 21:26:46
没有任何代码可以查看和理解您正在做什么,在我看来,要么是正在读取的文件( csv)采用了意想不到的编码。
如果你在某个时候打开文件,你需要确保它是用正确的编码读取的,或者是作为文本文件打开的(我在下面使用了utf8,但如果这不起作用,你可能需要弄清楚它是什么编码。
csvfile = open('my.csv', "rt", encoding='utf8')如果你没有打开文件,而打开是在库中发生的,那么它可能仍然是正在读取的内容的错误编码-也许数据应该是utf8,但它是某种windows格式?
您将需要向问题中添加代码,以便我们可以检查发生了什么,但是,如果这些都不能解决问题。
发布于 2019-03-09 03:22:25
Aunit已经打了补丁,支持python (2和3)的两个版本。
感谢您提出这个问题。
项目上的拉取请求也是受欢迎的。
https://stackoverflow.com/questions/54905259
复制相似问题