I am trying to get a coverage report on my code by running the following command:
python3 -m pytest --cov-config=.coveragerc --cov=main/lambda_function tests
I am running the command in the terminal of pycharm within the repo and my main code is located under main/lambda_function.
I did have a .coveragerc configured correctly but once I relocated the lambda_function file under main, my coverage report stopped working:
[run]
source =
lambda_function
rds_config
[paths]
source =
src/lambda_function
[report]
show_missing = true
precision = 2
I have attempted to add main/ but I get the error:
Coverage.py warning: Module main/lambda_function was never imported. (module-not-imported)
Coverage.py warning: No data was collected. (no-data-collected)
WARNING: Failed to generate report: No data to report.
What am I missing?
The value of --cov should be a path as documented:
--cov=PATH
Measure coverage for filesystem path. (multi-allowed)
Try changing the coverage path to the containing directory main
python3 -m pytest --cov-config=.coveragerc --cov=main tests
Or try using the python module name notation of using dot .
and without the file extension main.lambda_function
python3 -m pytest --cov-config=.coveragerc --cov=main.lambda_function tests