13 import sysconfig |
13 import sysconfig |
14 import traceback |
14 import traceback |
15 |
15 |
16 from coverage import env |
16 from coverage import env |
17 from coverage.disposition import FileDisposition, disposition_init |
17 from coverage.disposition import FileDisposition, disposition_init |
18 from coverage.exceptions import CoverageException |
18 from coverage.exceptions import CoverageException, PluginError |
19 from coverage.files import TreeMatcher, FnmatchMatcher, ModuleMatcher |
19 from coverage.files import TreeMatcher, FnmatchMatcher, ModuleMatcher |
20 from coverage.files import prep_patterns, find_python_files, canonical_filename |
20 from coverage.files import prep_patterns, find_python_files, canonical_filename |
21 from coverage.misc import sys_modules_saved |
21 from coverage.misc import sys_modules_saved |
22 from coverage.python import source_for_file, source_for_morf |
22 from coverage.python import source_for_file, source_for_morf |
23 |
23 |
240 add_third_party_paths(self.third_paths) |
240 add_third_party_paths(self.third_paths) |
241 |
241 |
242 def debug(msg): |
242 def debug(msg): |
243 if self.debug: |
243 if self.debug: |
244 self.debug.write(msg) |
244 self.debug.write(msg) |
|
245 |
|
246 # Generally useful information |
|
247 debug("sys.path:" + "".join(f"\n {p}" for p in sys.path)) |
245 |
248 |
246 # Create the matchers we need for should_trace |
249 # Create the matchers we need for should_trace |
247 if self.source or self.source_pkgs: |
250 if self.source or self.source_pkgs: |
248 against = [] |
251 against = [] |
249 if self.source: |
252 if self.source: |
390 disp.trace = True |
393 disp.trace = True |
391 disp.source_filename = canonical |
394 disp.source_filename = canonical |
392 |
395 |
393 if not disp.has_dynamic_filename: |
396 if not disp.has_dynamic_filename: |
394 if not disp.source_filename: |
397 if not disp.source_filename: |
395 raise CoverageException( |
398 raise PluginError( |
396 f"Plugin {plugin!r} didn't set source_filename for '{disp.original_filename}'" |
399 f"Plugin {plugin!r} didn't set source_filename for '{disp.original_filename}'" |
397 ) |
400 ) |
398 reason = self.check_include_omit_etc(disp.source_filename, frame) |
401 reason = self.check_include_omit_etc(disp.source_filename, frame) |
399 if reason: |
402 if reason: |
400 nope(disp, reason) |
403 nope(disp, reason) |