2

我是 python 和 bdd 的新手,需要一些帮助。我正在尝试从 python 行为中获取 junit 报告,但是在每次测试后我都收到了这个错误:

Traceback (most recent call last):
  File "C:\Program Files (x86)\JetBrains\PyCharm 4.5.4\helpers\pycharm\behave_runner.py", line 271, in <module>
_BehaveRunner(my_config, base_dir).run()
  File "C:\Program Files (x86)\JetBrains\PyCharm 4.5.4\helpers\pycharm\_bdd_utils.py", line 96, in run
self._run_tests()
  File "C:\Program Files (x86)\JetBrains\PyCharm 4.5.4\helpers\pycharm\behave_runner.py", line 189, in _run_tests
self.__real_runner.run()
  File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\site-packages\behave\runner.py", line 672, in run
return self.run_with_paths()
  File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\site-packages\behave\runner.py", line 693, in run_with_paths
return self.run_model()
  File "C:\Program Files (x86)\JetBrains\PyCharm 4.5.4\helpers\pycharm\behave_runner.py", line 112, in run_model
return super(_RunnerWrapper, self).run_model(features)
  File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\site-packages\behave\runner.py", line 483, in run_model
failed = feature.run(self)
  File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\site-packages\behave\model.py", line 523, in run
failed = scenario.run(runner)
  File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\site-packages\behave\model.py", line 914, in run
self.stdout = runner.context.stdout_capture.getvalue()
  File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\site-packages\behave\runner.py", line 214, in __getattr__
raise AttributeError(msg)

  AttributeError: 'Context' object has no attribute 'stdout_capture'

顺便说一下,behavior.ini 中的标志是下一个:

[behave]
junit=True
stdout_capture=True
stderr_capture=True
4

1 回答 1

1

我解决这个问题。如果您像我一样使用 ide 运行测试(PyCharm),然后尝试从命令行运行它,一切都应该正常工作。

于 2015-12-09T13:12:49.200 回答