Muhammad Zaman
Muhammad Zaman

Reputation: 280

How to Exclude files from coverage?

I am running my unit tests. But I want to exclude some folders and files during tests.

Here is my .coveragerc file

[run]
 branch = True
 source = .
 omit =
  Amazon_customers/.coveragerc
  amazon_customers/tests
  Amazon_customers/__init__.py
  Amazon_customers/urls.py
  Amazon_customers/wsgi.py
  amazon_customers/test_utils/*
  /migrations/
  /manage.py/

I need to exclude these files but it is not working.

Upvotes: 5

Views: 8607

Answers (2)

anjaneyulubatta505
anjaneyulubatta505

Reputation: 11665

Change your configuration file as below. it's better to provide the full path of file or folder/directory

[run]
 branch = True
 source = .
 omit =
  /home/myuser/Amazon_customers/.coveragerc   # file skip
  /home/myuser/amazon_customers/tests/*       # directory skip

For more information read https://coverage.readthedocs.io/en/latest/source.html#execution

Upvotes: 0

Muhammad Zaman
Muhammad Zaman

Reputation: 280

Finally got the solution:

[run]
 omit =
 */environment/*
 */migrations/*
  Amazon_customers/*
  manage.py

Upvotes: 6

Related Questions