Code coverage warning: "No source for code: '/my/local/folder/_run_response_middleware'. (couldnt-parse)"
See original GitHub issueDescribe the bug
After upgrade sanic from 21.6 to 21.9, coverage, we noticed when run coverage xml
, there is an error like below:
No source for code: '/my/local/folder/_run_request_middleware'.
with coverage xml -i
there are more warnings:
/my/local/virtualenv/lib/python3.8/site-packages/coverage/report.py:87: CoverageWarning: Couldn't parse '/my/local/folder/_run_request_middleware': No source for code: '/my/local/folder/_run_request_middleware'. (couldnt-parse)
coverage._warn(msg, slug="couldnt-parse")
/my/local/virtualenv/lib/python3.8/site-packages/coverage/report.py:87: CoverageWarning: Couldn't parse '/my/local/folder/_run_response_middleware': No source for code: '/my/local/folder/_run_response_middleware'. (couldnt-parse)
coverage._warn(msg, slug="couldnt-parse")
/my/local/virtualenv/lib/python3.8/site-packages/coverage/report.py:87: CoverageWarning: Couldn't parse '/my/local/folder/connection_task': No source for code: '/my/local/folder/connection_task'. (couldnt-parse)
coverage._warn(msg, slug="couldnt-parse")
/my/local/virtualenv/lib/python3.8/site-packages/coverage/report.py:87: CoverageWarning: Couldn't parse '/my/local/folder/handle_exception': No source for code: '/my/local/folder/handle_exception'. (couldnt-parse)
coverage._warn(msg, slug="couldnt-parse")
/my/local/virtualenv/lib/python3.8/site-packages/coverage/report.py:87: CoverageWarning: Couldn't parse '/my/local/folder/handle_request': No source for code: '/my/local/folder/handle_request'. (couldnt-parse)
coverage._warn(msg, slug="couldnt-parse")
/my/local/virtualenv/lib/python3.8/site-packages/coverage/report.py:87: CoverageWarning: Couldn't parse '/my/local/folder/http1_request_header': No source for code: '/my/local/folder/http1_request_header'. (couldnt-parse)
coverage._warn(msg, slug="couldnt-parse")
/my/local/virtualenv/lib/python3.8/site-packages/coverage/report.py:87: CoverageWarning: Couldn't parse '/my/local/folder/http1_response_header': No source for code: '/my/local/folder/http1_response_header'. (couldnt-parse)
coverage._warn(msg, slug="couldnt-parse")
/my/local/virtualenv/lib/python3.8/site-packages/coverage/report.py:87: CoverageWarning: Couldn't parse '/my/local/folder/read': No source for code: '/my/local/folder/read'. (couldnt-parse)
coverage._warn(msg, slug="couldnt-parse")
/my/local/virtualenv/lib/python3.8/site-packages/coverage/report.py:87: CoverageWarning: Couldn't parse '/my/local/folder/send': No source for code: '/my/local/folder/send'. (couldnt-parse)
coverage._warn(msg, slug="couldnt-parse")
Wrote XML report to coverage.xml
Code snippet
In blueprint.py
my_bp = Blueprint("my_blueprint")
Create app in a different file:
my_app = Sanic(name, load_env=False, log_config=LOG_SETTINGS)
my_app.blueprint(my_bp)
my_app.register_middleware( ..... )
Expected behavior No warning or error while generating code coverage report, like using sanic 21.6.
Environment (please complete the following information):
- OS: Ubuntu 20.04
- Version 21.9 and 21.12, not repro on 21.6
- Python: 3.8
Additional context
$ pip freeze | grep "sanic\|coverage\|pytest"
coverage==6.2
pytest==6.2.5
pytest-asyncio==0.15.1
sanic==21.9.3
sanic-routing==0.7.2
sanic-testing==0.8.2
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Noisy CoverageWarnings No source for code in pep517-build ...
Since these files are unrelated to the project and since these warnings aren't emitted when running coverage natively, I'd expect these warnings ......
Read more >Release 7.0.0b1 unknown - Coverage.py
Coverage.py can annotate your source code to show which lines were executed and which were not. The html command creates an HTML report...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Why are you running coverage for Sanic?
You will not get coverage for these functions because they are rewritten at startup time based upon your application’s code.
I am closing this now as the issue is not really related to Sanic. Feel free to continue the conversation.