nedbat / coveragepy

The code coverage tool for Python
https://coverage.readthedocs.io
Apache License 2.0
3.01k stars 433 forks source link

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

Open DotNetTechSoln opened 2 months ago

DotNetTechSoln commented 2 months ago

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.

nedbat commented 2 months ago

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