{"id":947,"hash":"5d5eb956f89fc020a04bfc95dcb10ea8804f76969a86cc950daa5e7c64671589","pattern":"python coverage output: Coverage.py warning: No data was collected. (no-data-collected)","full_message":"I am trying to find the coverage using the coverage module for a django project but gets\n\nCoverage.py warning: No data was collected. (no-data-collected)\n\nMy project folder has src and tests folders.\n\nWhen I run\n\ncoverage run -m pytest && coverage report\n\nIt produces a report with 100% coverage with the list of files inside the tests folder.\nWhereas when I run\n\ncoverage run --source=src -m pytest && coverage report\n\nit says\n\nCoverage.py warning: No data was collected. (no-data-collected)\nNo data to report.\n\nWhen I try to give the source=src or include=src in the .coveragerc also the same warning occurs. The tests passes for all the above cases.\n\nI want the coverage of the src folder.\nIs it because I am missing some path setting?","ecosystem":"pypi","package_name":"django","package_version":null,"solution":"coverage (used by pytest-cov) needs the tests folder to contain an __init__.py before it will collect any data.\n\nI added __init__.py to the tests folder and then coverage collected the data as expected.\n\nRefer to http://thomas-cokelaer.info/blog/2017/01/pytest-cov-collects-no-data-on-travis/","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/47287721/python-coverage-output-coverage-py-warning-no-data-was-collected-no-data-col","votes":84,"created_at":"2026-04-19T04:52:04.241461+00:00","updated_at":"2026-04-19T04:52:04.241461+00:00"}