Run trace.py with pytest

为君一笑 提交于 2020-03-03 03:03:08

问题


I'm trying to get coverage using trace.py when running pytest. I know that pytest has its own coverage plugin pytest-cov but restrictions (number of times each line is executed is unavailable) do not allow me to use that right now. The same for coverage.py

I'm trying this command: python3.4 -m trace -c -m -C . pytest test_script.py

test_script.py:

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

The output is:

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 obviously expects a file in its arguments and not another module. How can I modify this command to get trace.py working with pytest?

Edit: I was able to find a way to get this done

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

来源:https://stackoverflow.com/questions/47747733/run-trace-py-with-pytest

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!