File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -268,6 +268,7 @@ def __init__( # pylint: disable=too-many-arguments
268
268
self ._warn_preimported_source = check_preimported
269
269
self ._no_warn_slugs : set [str ] = set ()
270
270
self ._messages = messages
271
+ self ._patch_pth_file = True
271
272
272
273
# A record of all the warnings that have been issued.
273
274
self ._warnings : list [str ] = []
@@ -678,7 +679,7 @@ def start(self) -> None:
678
679
if self ._auto_load :
679
680
self .load ()
680
681
681
- apply_patches (self , self .config )
682
+ apply_patches (self , self .config , pth_file = self . _patch_pth_file )
682
683
683
684
self ._collector .start ()
684
685
self ._started = True
@@ -1432,6 +1433,7 @@ def process_startup() -> Coverage | None:
1432
1433
cov ._warn_unimported_source = False
1433
1434
cov ._warn_preimported_source = False
1434
1435
cov ._auto_save = True
1436
+ cov ._patch_pth_file = False
1435
1437
cov .start ()
1436
1438
1437
1439
return cov
Original file line number Diff line number Diff line change 19
19
from coverage .config import CoverageConfig
20
20
21
21
22
- def apply_patches (cov : Coverage , config : CoverageConfig ) -> None :
22
+ def apply_patches (cov : Coverage , config : CoverageConfig , * , pth_file : bool = True ) -> None :
23
23
"""Apply invasive patches requested by `[run] patch=`."""
24
24
25
25
for patch in sorted (set (config .patch )):
@@ -78,9 +78,10 @@ def coverage_execv_patch(*args: Any, **kwargs: Any) -> Any:
78
78
os .execve = make_execv_patch ("execve" , os .execve )
79
79
80
80
elif patch == "subprocess" :
81
- pth_file = create_pth_file ()
82
- assert pth_file is not None
83
- atexit .register (pth_file .unlink , missing_ok = True )
81
+ if pth_file :
82
+ pth_file = create_pth_file ()
83
+ assert pth_file is not None
84
+ atexit .register (pth_file .unlink , missing_ok = True )
84
85
assert config .config_file is not None
85
86
os .environ ["COVERAGE_PROCESS_START" ] = config .config_file
86
87
You can’t perform that action at this time.
0 commit comments