File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
python_files/vscode_pytest Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -442,13 +442,29 @@ 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 .exceptions import NoSource
445446
446447 cov = coverage .Coverage ()
447448 cov .load ()
449+
450+ # omit file playground
451+ config = cov .config
452+ # omit_patterns = config.omit
453+ exclude_patterns = config .exclude_list
454+ cov_ex_list = cov .get_exclude_list ()
455+
456+ # print("Omitted files patterns:", omit_patterns)
457+ print ("Excluded code patterns:" , exclude_patterns )
458+ print ("Excluded code patterns:" , cov_ex_list )
459+
448460 file_set : set [str ] = cov .get_data ().measured_files ()
449461 file_coverage_map : dict [str , FileCoverageInfo ] = {}
450462 for file in file_set :
451- analysis = cov .analysis2 (file )
463+ try :
464+ analysis = cov .analysis2 (file )
465+ except NoSource :
466+ # as per issue 24308 this best way to handle this edge case
467+ continue
452468 lines_executable = {int (line_no ) for line_no in analysis [1 ]}
453469 lines_missed = {int (line_no ) for line_no in analysis [3 ]}
454470 lines_covered = lines_executable - lines_missed
You can’t perform that action at this time.
0 commit comments