question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Code coverage warning: "No source for code: '/my/local/folder/_run_response_middleware'. (couldnt-parse)"

See original GitHub issue

Describe 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:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ahopkinscommented, Dec 29, 2021

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.

0reactions
ahopkinscommented, Dec 29, 2021

I am closing this now as the issue is not really related to Sanic. Feel free to continue the conversation.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found