Skip to content

Commit bf46284

Browse files
Fix 'coverage.exceptions.NoSource` import to fallback to previous exception path (#24608)
Fixes #24607
1 parent 6971fda commit bf46284

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

python_files/vscode_pytest/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,11 @@ def pytest_sessionfinish(session, exitstatus):
442442
if is_coverage_run == "True":
443443
# load the report and build the json result to return
444444
import coverage
445-
from coverage import exceptions
445+
446+
try:
447+
from coverage.exceptions import NoSource
448+
except ImportError:
449+
from coverage.misc import NoSource
446450

447451
cov = coverage.Coverage()
448452
cov.load()
@@ -462,7 +466,7 @@ def pytest_sessionfinish(session, exitstatus):
462466
for file in file_set:
463467
try:
464468
analysis = cov.analysis2(file)
465-
except exceptions.NoSource:
469+
except NoSource:
466470
# as per issue 24308 this best way to handle this edge case
467471
continue
468472
lines_executable = {int(line_no) for line_no in analysis[1]}

0 commit comments

Comments
 (0)