coveragepy icon indicating copy to clipboard operation
coveragepy copied to clipboard

I am writing unit test cases for python file using pytest framework

Open DotNetTechSoln opened this issue 1 year ago • 1 comments

When I am trying to run the test case i am able to run it.using following command

pytest In the output I can see this test_sample.py 100%

When I am trying to run the following command to see whole line coverage

coverage run -m pytest I am getting below error Windows fatal exception: access violation when I hit coverage html It is saying no data to report Even . coverage file is also not generating. anyone please help me.

DotNetTechSoln avatar Aug 13 '24 16:08 DotNetTechSoln

I suspect this is something to do with having more than one Python installation. For example, take a look at the output of these commands:

$ which pytest
$ which coverage
$ which python

The best practice is to always run python as the command:

$ python -m pip install ....
$ python -m pytest
$ python -m coverage run -m pytest
etc

nedbat avatar Aug 13 '24 19:08 nedbat