使用pytest运行trace.py

问题描述 投票:3回答:1

我正在尝试运行trace.py时使用pytest进行覆盖。我知道pytest有自己的coverage插件pytest-cov,但是限制(每行执行的次数不可用)现在不允许我使用。 coverage.py

相同

我正在尝试以下命令:python3.4 -m trace -c -m -C . pytest test_script.py

test_script.py

class TestScript():
    def test_print(self):
        print ('Hello')

输出为:

nikhilh$ python3.4 -m trace -c -m -C . pytest test_script.py
pytest: Cannot run file 'pytest' because: [Errno 2] No such file or directory: 'pytest'

trace.py显然期望其参数中包含文件,而不是其他模块。如何修改此命令以使trace.pypytest一起使用?

编辑:我能够找到一种方法来完成此任务

nikhilh$ python3.4 -m trace -c -m -C . <pytest_script_absolute_path> test_script.py

python-3.x pytest trace pytest-cov
1个回答
1
投票

听到大卫的评论,所以这是我当时使用的答案:

python3.4 -m trace -c -m -C . <pytest_script_absolute_path> test_script.py

© www.soinside.com 2019 - 2024. All rights reserved.