Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 即使测试失败,Pytest也会返回状态代码0 请考虑以下批处理脚本: call <somepath>/py.test.exe <someotherpath>/tests if %errorlevel%==0 ( echo Tests successful. ) else ( echo Tests failed. ) 调用/py.test.exe/tests 如果%errorlevel%==0( 回声测试成功。 )否则( 回声测试失败。 )_Python_Batch File_Pytest - Fatal编程技术网

Python 即使测试失败,Pytest也会返回状态代码0 请考虑以下批处理脚本: call <somepath>/py.test.exe <someotherpath>/tests if %errorlevel%==0 ( echo Tests successful. ) else ( echo Tests failed. ) 调用/py.test.exe/tests 如果%errorlevel%==0( 回声测试成功。 )否则( 回声测试失败。 )

Python 即使测试失败,Pytest也会返回状态代码0 请考虑以下批处理脚本: call <somepath>/py.test.exe <someotherpath>/tests if %errorlevel%==0 ( echo Tests successful. ) else ( echo Tests failed. ) 调用/py.test.exe/tests 如果%errorlevel%==0( 回声测试成功。 )否则( 回声测试失败。 ),python,batch-file,pytest,Python,Batch File,Pytest,然而,即使当pytest测试失败时,我也能成功地进行测试。发生了什么?可能是重复的:首先,在批处理文件中,不需要使用命令调用来运行可执行文件并停止批处理文件的执行,直到可执行文件自身终止。命令调用主要用于从批处理文件中调用另一个批处理文件。因此,我建议首先从第一行中删除call。接下来,我建议打开一个命令提示符窗口并运行if/?。输出帮助在第一页解释了如何使用语法if[not]errorlevel number command评估命令或可执行文件的退出代码,该语法也适用于以(开始,以匹配结束的命

然而,即使当
pytest
测试失败时,我也能成功地进行
测试。发生了什么?

可能是重复的:首先,在批处理文件中,不需要使用命令调用来运行可执行文件并停止批处理文件的执行,直到可执行文件自身终止。命令调用主要用于从批处理文件中调用另一个批处理文件。因此,我建议首先从第一行中删除
call
。接下来,我建议打开一个命令提示符窗口并运行
if/?
。输出帮助在第一页解释了如何使用语法
if[not]errorlevel number command
评估命令或可执行文件的退出代码,该语法也适用于以
开始,以匹配
结束的命令块
)。因此,如果errorlevel 1(回显测试失败),则使用第二行
,否则回显测试成功。
另请参阅,以获取评估应用程序或命令退出代码的替代方法。