@@ -52,12 +52,12 @@ def setup():
5252
5353def subprocess_run_for_testing (
5454 command : "list[str]" ,
55- env : "dict[str, str]" ,
55+ env : "dict[str, str]" = None ,
5656 timeout : float = None ,
5757 stdout = None ,
5858 stderr = None ,
5959 check = False ,
60- universal_newlines = True ,
60+ text = True ,
6161 capture_output = False
6262) -> "subprocess.Popen" :
6363 """
@@ -72,7 +72,11 @@ def subprocess_run_for_testing(
7272 timeout : float
7373 stdout, stderr
7474 check : bool
75- universal_newlines : bool
75+ text : bool
76+ Also called `universal_newlines` in subprocess. I chose this
77+ name since the main effect is returning bytes (False) vs. str
78+ (True), though it also tries to normalize newlines across
79+ platforms.
7680 capture_output : bool
7781 Set stdout and stderr to subprocess.PIPE
7882
@@ -96,7 +100,7 @@ def subprocess_run_for_testing(
96100 command , env = env ,
97101 timeout = timeout , check = check ,
98102 stdout = stdout , stderr = stderr ,
99- universal_newlines = universal_newlines
103+ text = text
100104 )
101105 except BlockingIOError :
102106 if sys .platform == "cygwin" :
@@ -124,15 +128,18 @@ def subprocess_run_helper(func, *args, timeout, extra_env=None):
124128 target = func .__name__
125129 module = func .__module__
126130 proc = subprocess_run_for_testing (
127- [sys .executable ,
128- "-c" ,
129- f"from { module } import { target } ; { target } ()" ,
130- * args ],
131+ [
132+ sys .executable ,
133+ "-c" ,
134+ f"from { module } import { target } ; { target } ()" ,
135+ * args
136+ ],
131137 env = {** os .environ , "SOURCE_DATE_EPOCH" : "0" , ** (extra_env or {})},
132138 timeout = timeout , check = True ,
133139 stdout = subprocess .PIPE ,
134140 stderr = subprocess .PIPE ,
135- universal_newlines = True )
141+ text = True
142+ )
136143 return proc
137144
138145
0 commit comments