gpt4 book ai didi

python - '上下文'对象没有属性 'stdout_capture'

转载 作者:太空宇宙 更新时间:2023-11-04 05:40:44 24 4
gpt4 key购买 nike

我是 python 和 bdd 的新手,需要一些帮助。我正在尝试从 python behave 获取 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'

顺便说一句,接下来是 behave.ini 中的标志:

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

最佳答案

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

关于python - '上下文'对象没有属性 'stdout_capture',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34014355/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com