Run trace.py with pytest

1.3k Views Asked by At

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

1

There are 1 best solutions below

2
On BEST ANSWER

Came across David's comment, so here's the answer that I used at that time:

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