@@ -124,12 +124,6 @@ def handle_sig(self, sig, frame):
124
124
125
125
@staticmethod
126
126
def handle_sighup (signum , frame ):
127
- # bpo-38547: if the process is the session leader, os.close(master_fd)
128
- # of "master_fd, slave_name = pty.master_open()" raises SIGHUP
129
- # signal: just ignore the signal.
130
- #
131
- # NOTE: the above comment is from an older version of the test;
132
- # master_open() is not being used anymore.
133
127
pass
134
128
135
129
@expectedFailureIfStdinIsTTY
@@ -191,13 +185,6 @@ def test_openpty(self):
191
185
self .assertEqual (_get_term_winsz (slave_fd ), new_stdin_winsz ,
192
186
"openpty() failed to set slave window size" )
193
187
194
- # Solaris requires reading the fd before anything is returned.
195
- # My guess is that since we open and close the slave fd
196
- # in master_open(), we need to read the EOF.
197
- #
198
- # NOTE: the above comment is from an older version of the test;
199
- # master_open() is not being used anymore.
200
-
201
188
# Ensure the fd is non-blocking in case there's nothing to read.
202
189
blocking = os .get_blocking (master_fd )
203
190
try :
@@ -325,12 +312,17 @@ def test_master_read(self):
325
312
326
313
self .assertEqual (data , b"" )
327
314
315
+ def test_spawn_doesnt_hang (self ):
316
+ pty .spawn ([sys .executable , '-c' , 'print("hi there")' ])
317
+
328
318
class SmallPtyTests (unittest .TestCase ):
329
319
"""These tests don't spawn children or hang."""
330
320
331
321
def setUp (self ):
332
322
self .orig_stdin_fileno = pty .STDIN_FILENO
333
323
self .orig_stdout_fileno = pty .STDOUT_FILENO
324
+ self .orig_pty_close = pty .close
325
+ self .orig_pty__copy = pty ._copy
334
326
self .orig_pty_fork = pty .fork
335
327
self .orig_pty_select = pty .select
336
328
self .orig_pty_setraw = pty .setraw
@@ -346,6 +338,8 @@ def setUp(self):
346
338
def tearDown (self ):
347
339
pty .STDIN_FILENO = self .orig_stdin_fileno
348
340
pty .STDOUT_FILENO = self .orig_stdout_fileno
341
+ pty .close = self .orig_pty_close
342
+ pty ._copy = self .orig_pty__copy
349
343
pty .fork = self .orig_pty_fork
350
344
pty .select = self .orig_pty_select
351
345
pty .setraw = self .orig_pty_setraw
0 commit comments