1

I have come up with this issue, where by following the instructions found in the coverage.py page I end up getting the report on the test files themselves instead of the application files. I am referring to a Flask application, using unittest as a testing framework, and coverage.py for coverage reports.

The project's folder tree can be represented as follows:

+ root
+
++++ Server
   +
   ++++ server.py
   ++++ Models
      +
      ++++ other_files
    +
++++ Tests
   +
   ++++ test_file.py

If I use the command:

coverage run -m unittest discover && coverage report

I get:

Name                      Stmts   Miss  Cover
---------------------------------------------
Models\__init__.py            0      0   100%
test_1.py                    76     16    79%
test_2.py                    67      3    96%
---------------------------------------------
TOTAL                       143     19    87%

Where the output I get doesn't refer to the ApplicationFile(s).py.

If instead I use:

coverage run --source ./../ApplicationFile.py -m unittest discover && coverage report

I get:

Coverage.py warning: Module ./../ApplicationFile.py was never imported. (module-not-imported)
Coverage.py warning: No data was collected. (no-data-collected)
No data to report.

Does someone have an idea of where the issue could be?

Pharaoh
  • 13
  • 3

1 Answers1

0

I think --source is expecting a directory rather than a file. Try instead coverage run --source ./../ -m unittest discover && coverage report

Mohamed Feddad
  • 204
  • 2
  • 8
  • Hello, by pointing at the source files folder I still get the "No data was collected" warning, but not the "was never imported" message. – Pharaoh Jul 06 '20 at 10:37
  • Hi, not sure why is that happening. I've just tested it locally with a mock project, seems to work https://imgur.com/ZyTYZmH – Mohamed Feddad Jul 06 '20 at 11:32
  • Is the project structure similar to that I have drawn? I tried again but the same error occurs – Pharaoh Jul 06 '20 at 13:40