@@ -52,12 +52,12 @@ def setup():
52
52
53
53
def subprocess_run_for_testing (
54
54
command : "list[str]" ,
55
- env : "dict[str, str]" ,
55
+ env : "dict[str, str]" = None ,
56
56
timeout : float = None ,
57
57
stdout = None ,
58
58
stderr = None ,
59
59
check = False ,
60
- universal_newlines = True ,
60
+ text = True ,
61
61
capture_output = False
62
62
) -> "subprocess.Popen" :
63
63
"""
@@ -72,7 +72,11 @@ def subprocess_run_for_testing(
72
72
timeout : float
73
73
stdout, stderr
74
74
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.
76
80
capture_output : bool
77
81
Set stdout and stderr to subprocess.PIPE
78
82
@@ -96,7 +100,7 @@ def subprocess_run_for_testing(
96
100
command , env = env ,
97
101
timeout = timeout , check = check ,
98
102
stdout = stdout , stderr = stderr ,
99
- universal_newlines = universal_newlines
103
+ text = text
100
104
)
101
105
except BlockingIOError :
102
106
if sys .platform == "cygwin" :
@@ -124,15 +128,18 @@ def subprocess_run_helper(func, *args, timeout, extra_env=None):
124
128
target = func .__name__
125
129
module = func .__module__
126
130
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
+ ],
131
137
env = {** os .environ , "SOURCE_DATE_EPOCH" : "0" , ** (extra_env or {})},
132
138
timeout = timeout , check = True ,
133
139
stdout = subprocess .PIPE ,
134
140
stderr = subprocess .PIPE ,
135
- universal_newlines = True )
141
+ text = True
142
+ )
136
143
return proc
137
144
138
145
0 commit comments