Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.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 3.x Pytest能否在预定时间运行?_Python 3.x_Scheduled Tasks_Pytest_Scheduler - Fatal编程技术网

Python 3.x Pytest能否在预定时间运行?

Python 3.x Pytest能否在预定时间运行?,python-3.x,scheduled-tasks,pytest,scheduler,Python 3.x,Scheduled Tasks,Pytest,Scheduler,我正在使用pytest运行我的测试,使用python3脚本,如下所示: pytest -s test_file.py | tee -a myoutput.log 它起作用了。现在我想每天在特定的时间运行它,我在linux控制台上尝试了“crontab-e”,但失败了。我的意思是“myoutput.log”文件中没有添加日志。有人能帮忙吗?谢谢 42 00 * * * /usr/bin/pytest pytest -s /data/smc/test_file.py | tee -a myoutp

我正在使用pytest运行我的测试,使用python3脚本,如下所示:

pytest -s test_file.py | tee -a myoutput.log
它起作用了。现在我想每天在特定的时间运行它,我在linux控制台上尝试了“crontab-e”,但失败了。我的意思是“myoutput.log”文件中没有添加日志。有人能帮忙吗?谢谢

42 00 * * * /usr/bin/pytest pytest -s /data/smc/test_file.py | tee -a myoutput.log

我认为这可以通过使用cron输出来实现。例如:


42 00***/usr/bin/pytest-pytest-s/data/smc/test_file.py>/Your-log-path.log 2>&1

如果您可以为“但失败”位添加更多细节,这将大大有助于我们帮助您:-)
/usr/bin/pytest-pytest
部分怎么了?我几乎可以肯定这是错误源。此外,如果命令的stdout为空,bash中的常见习惯用法是将stderr输出重定向到stdout(
command 2>&1
),因此如果命令由于某些原因失败,您可以在日志中看到错误。如果在修复了两个可执行文件的问题后仍然出现错误,请尝试一下。/usr/bin/pytest这是环境,而“pytest-s”是运行文件的命令。当我从python控制台而不是crontab运行命令时,它工作得很好。
/usr/bin/pytest
看起来像是指向
pytest
可执行文件的路径
/usr/bin/pytest pytest
错误,省略其中一个.42 00***/usr/local/bin/pytest/data/smc/test_file.py>/Your-log-path.log 2>&1现在可以使用了。我的意思是,我得到的pytest输出是通过/失败的结果,但我失去了使用print命令的输出,而我可以使用“pytest-s”获得该命令。有什么线索吗?终于找到了!42 00***/usr/local/bin/pytest/data/smc/test_file.py-s>>/Your-log-path.log 2>&1