4

I've written tests for my python code and want to check how much % is covered with tests, so I decided to use python coverage. But I have a problem launching it. I launch my tests with this bash command:

export PYTHONPATH=. && python files/test/tests.py

My python program is in "files" directory, and tests are in "test", so I can't launch it another way. Using

export PYTHONPATH=. && python coverage files/test/tests.py

raises Error. How to correctly use coverage in my situation ?

oz123
  • 27,559
  • 27
  • 125
  • 187
user2876296
  • 97
  • 2
  • 7

2 Answers2

2

The correct way to do this is to use an appropriate coverage plugin for the unit testing framework/runner you are using:

Here are some combinations:

There are probably other tools and combinations you can use. But these two are probably the most common (no reference).

James Mills
  • 18,669
  • 3
  • 49
  • 62
1
coverage run files/test/tests.py
attaboyabhipro
  • 1,450
  • 1
  • 17
  • 33