19
19
import types
20
20
import _thread
21
21
22
- from typing import (
23
- overload ,
24
- Any , Callable , Final , IO ,
25
- )
22
+ from typing import overload , Any , Callable , Final , IO
26
23
from collections .abc import Iterable , Iterator , Mapping
27
24
25
+ from coverage import env
28
26
from coverage .misc import human_sorted_items , isolate_module
29
27
from coverage .types import AnyCallable , TWritable
30
28
35
33
# debugging the configuration mechanisms you usually use to control debugging!
36
34
# This is a list of forced debugging options.
37
35
FORCED_DEBUG : list [str ] = []
38
- FORCED_DEBUG_FILE = None
36
+ FORCED_DEBUG_FILE = ""
39
37
40
38
41
39
class DebugControl :
@@ -402,7 +400,7 @@ def __init__(self) -> None:
402
400
403
401
def filter (self , text : str ) -> str :
404
402
"""Add a message when the pytest test changes."""
405
- test_name = os .getenv ("PYTEST_CURRENT_TEST" )
403
+ test_name = env .getenv ("PYTEST_CURRENT_TEST" )
406
404
if test_name != self .test_name :
407
405
text = f"Pytest context: { test_name } \n " + text
408
406
self .test_name = test_name
@@ -452,7 +450,7 @@ def get_one(
452
450
fileobj = open (file_name , "a" , encoding = "utf-8" )
453
451
else :
454
452
# $set_env.py: COVERAGE_DEBUG_FILE - Where to write debug output
455
- file_name = os .getenv ("COVERAGE_DEBUG_FILE" , FORCED_DEBUG_FILE )
453
+ file_name = env .getenv ("COVERAGE_DEBUG_FILE" , FORCED_DEBUG_FILE )
456
454
if file_name in ("stdout" , "stderr" ):
457
455
fileobj = getattr (sys , file_name )
458
456
elif file_name :
@@ -587,14 +585,14 @@ def _wrapper(self: Any, *args: Any, **kwargs: Any) -> Any:
587
585
return _decorator
588
586
589
587
590
- def relevant_environment_display (env : Mapping [str , str ]) -> list [tuple [str , str ]]:
588
+ def relevant_environment_display (env_map : Mapping [str , str ]) -> Iterable [tuple [str , str ]]:
591
589
"""Filter environment variables for a debug display.
592
590
593
591
Select variables to display (with COV or PY in the name, or HOME, TEMP, or
594
592
TMP), and also cloak sensitive values with asterisks.
595
593
596
594
Arguments:
597
- env : a dict of environment variable names and values.
595
+ env_map : a dict of environment variable names and values.
598
596
599
597
Returns:
600
598
A list of pairs (name, value) to show.
@@ -605,7 +603,7 @@ def relevant_environment_display(env: Mapping[str, str]) -> list[tuple[str, str]
605
603
cloak = {"API" , "TOKEN" , "KEY" , "SECRET" , "PASS" , "SIGNATURE" }
606
604
607
605
to_show = []
608
- for name , val in env .items ():
606
+ for name , val in env_map .items ():
609
607
keep = False
610
608
if name in include :
611
609
keep = True
0 commit comments