Python 登录到输出文件,并在behave中进行标准输出
当我将输出重定向到时,在运行期间,我无法在控制台中看到回溯 带有-o的日志示例:Python 登录到输出文件,并在behave中进行标准输出,python,python-3.x,python-behave,Python,Python 3.x,Python Behave,当我将输出重定向到时,在运行期间,我无法在控制台中看到回溯 带有-o的日志示例: 2021-05-24:14:42:52, INFO | environment.py :22 : Before all 2021-05-24:14:42:54, INFO | launch_test.py :144 : 1 2021-05-24:14:42:54, INFO | launch_test.py :147 : feature
2021-05-24:14:42:52, INFO | environment.py :22 : Before all
2021-05-24:14:42:54, INFO | launch_test.py :144 : 1
2021-05-24:14:42:54, INFO | launch_test.py :147 : feature: autogen_Generate_Cloud.feature | name: Run all projects from specified folder -- @1.1 Projects | project: Test_Beamer_Car1 | number: 1 --> FAILED
未启用-o选项的日志示例:
Exception TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType
2021-05-24:14:50:57, ERROR | launch_test.py :141 : Exception thrown during behave run
Traceback (most recent call last):
[REDACTED TRACEBACK]
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType
2021-05-24:14:50:57, INFO | launch_test.py :144 : 1
2021-05-24:14:50:57, INFO | launch_test.py :147 : feature: autogen_Generate_Cloud.feature | name: Run all projects from specified folder -- @1.1 Projects | project: Test_Beamer_Car1 | number: 1 --> FAILED
我想要达到的目标是什么?具有后一种日志格式,但输出也重定向到文件
我试了什么
- 在behave中关闭格式化程序和输出文件似乎可以完成这项工作
[PATH to feature files],
"--no-summary",
"-k",
"--no-junit",
"-f=allure_behave.formatter:AllureFormatter",
"--no-capture",
"--no-capture-stderr",
f"-i={scenario.feature}",
f"--name={scenario.name}",
f"-o={output_file}"
我需要使用AllureFormatter,因为程序使用allure生成报告,但它似乎捕获控制台输出并仅将其返回到文件,而不是stdout或stderr最后解析输出文件,并在测试状态为“中断”时打印回溯。不是特别干净的溶液,但是,嘿,它很有效