Skip to content

Commit

Permalink
Fix 'coverage.exceptions.NoSource` import to fallback to previous exc…
Browse files Browse the repository at this point in the history
…eption path (#24608)

Fixes #24607
  • Loading branch information
GeorgeNikitinNV authored Dec 17, 2024
1 parent 6971fda commit bf46284
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions python_files/vscode_pytest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,11 @@ def pytest_sessionfinish(session, exitstatus):
if is_coverage_run == "True":
# load the report and build the json result to return
import coverage
from coverage import exceptions

try:
from coverage.exceptions import NoSource
except ImportError:
from coverage.misc import NoSource

cov = coverage.Coverage()
cov.load()
Expand All @@ -462,7 +466,7 @@ def pytest_sessionfinish(session, exitstatus):
for file in file_set:
try:
analysis = cov.analysis2(file)
except exceptions.NoSource:
except NoSource:
# as per issue 24308 this best way to handle this edge case
continue
lines_executable = {int(line_no) for line_no in analysis[1]}
Expand Down

0 comments on commit bf46284

Please sign in to comment.