Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
703c1d1
migrating issue to github
diekmann Apr 10, 2017
78c165a
using subprocess.run to run pty.spawn
diekmann Apr 14, 2017
28e918e
move _mock_stdin_stdout to the actual tests
diekmann Apr 14, 2017
6e7f587
Get os.forkpty disabled again.
diekmann Apr 14, 2017
fd61cad
Yes, way less monkey patching.
diekmann Apr 14, 2017
e9b0b8b
Decoupling PtySpawnTestBase and PtyMockingTestBase
diekmann Apr 14, 2017
a42755b
Move PtyMockingTestBase closer to PtyCopyTests
diekmann Apr 14, 2017
7451f97
Tuned class hierarchy
diekmann Apr 14, 2017
b604d83
fix line length and error path of base classes
diekmann Apr 14, 2017
cbe7d14
clarify difference to alternatives
diekmann Apr 14, 2017
8afd1e7
move disable-os.forkpty-code closer to the test
diekmann Apr 14, 2017
2c3498f
cosmetic changes
diekmann Apr 14, 2017
ec58a62
polish
diekmann Apr 14, 2017
0be6c54
let exceptions out and fail the tests
diekmann Apr 14, 2017
250ae50
Pull related code for select mocking tests together
diekmann Apr 14, 2017
7ced6d8
Tune PtyCopyTests
diekmann Apr 14, 2017
528fc5d
unify code comments in PtySpawnTestBase
diekmann Apr 15, 2017
aeb6585
cosmetic changes
diekmann Apr 15, 2017
57876df
Cleanup of terminal setup code
diekmann Apr 15, 2017
2309d69
removed test_eof_echoctl
diekmann Apr 15, 2017
f93de8d
fixed echoing race
diekmann Apr 15, 2017
9cd9425
cleaned OS X workaround comments
diekmann Apr 15, 2017
a7e4753
Removed doc string from test methods.
diekmann Apr 15, 2017
5944764
Fixed comment
diekmann Apr 15, 2017
851c261
[CONTRIBUTING.rst] Added myself to Misc/ACKS
diekmann Jul 28, 2017
5dbc249
added Chris Torek to ACKS
diekmann Jul 28, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Removed doc string from test methods.
"Also, no documentation string for the method should be included. A
comment (such as # Tests function returns only True or False) should be
used to provide documentation for test methods. This is done because
documentation strings get printed out if they exist and thus what test
is being run is not stated." /Doc/build/html/library/test.html
  • Loading branch information
diekmann committed Jul 28, 2017
commit a7e47537f3402077a1c0d402e7d93afce5eb1937
48 changes: 21 additions & 27 deletions Lib/test/test_pty.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,18 +303,18 @@ def _spawn_py_get_retcode(self, python_src):
return retcode

def test_spawn_exitsuccess(self):
"""Spawn the python-equivalent of /bin/true."""
# Spawn the python-equivalent of /bin/true.
retcode = self._spawn_py_get_retcode('import sys; sys.exit()')
self.assertEqual(retcode, 0)

def test_spawn_exitfailure(self):
"""Spawn the python-equivalent of /bin/false."""
# Spawn the python-equivalent of /bin/false.
retcode = self._spawn_py_get_retcode('import sys; sys.exit(1)')
self.assertEqual(retcode, 1)

def test_spawn_uncommon_exit_code(self):
"""Test an uncommon exit code, which is less likely to be caused
by a Python exception or other failure."""
# Test an uncommon exit code, which is less likely to be caused
# by a Python exception or other failure.
retcode = self._spawn_py_get_retcode('import sys; sys.exit(81)')
self.assertEqual(retcode, 81)

Expand Down Expand Up @@ -541,8 +541,7 @@ def _background_process(to_stdin, from_stdout):
return 0 # success

def test_alternate_ping(self):
"""Spawn a slave and fork a master background process. Let them
Ping-Pong count to 1000 by turns."""
# Let background and slave Ping-Pong count to 1000 by turns.
child_code = self._EXEC_IMPORTS + self._EXEC_CHILD
self._spawn_master_and_slave(self._background_process, child_code)

Expand All @@ -557,10 +556,8 @@ def _mock_disabled_osforkpty():
os.forkpty = _mock_disabled_osforkpty
""".format(verbose))

def test_alternate_ping_disable_osforkpty(self):
"""Spawn a slave and fork a master background process. Let them
Ping-Pong count to 1000 by turns. Disable os.forkpty(), trigger
pty.fork() backup code."""
def test_ping_disable_osforkpty(self):
# Disable os.forkpty(), trigger pty.fork() fallback code path.
child_code = self._EXEC_IMPORTS + self._EXEC_CHILD
self._spawn_master_and_slave(self._background_process, child_code,
pre_spawn_hook=self._DISABLE_OS_FORKPTY)
Expand Down Expand Up @@ -600,16 +597,14 @@ def _background_process(to_stdin, from_stdout):
""")

def test_read(self):
"""Spawn a slave and fork a master background process. Receive
several kBytes from the slave."""
# Receive several kBytes from the slave.
child_code = self._EXEC_IMPORTS + \
self._EXEC_CHILD_FMT.format(sleeptime=0.05)
debug("Test may take up to 1 second ...")
self._spawn_master_and_slave(self._background_process, child_code)

def test_read_close_stdin(self):
"""Spawn a slave and fork a master background process. Close
STDIN and receive several kBytes from the slave."""
# Close STDIN and receive several kBytes from the slave.
# only sleep in one test to speed this up
child_code = self._EXEC_IMPORTS + \
self._EXEC_CHILD_FMT.format(sleeptime=0)
Expand Down Expand Up @@ -700,7 +695,7 @@ def _background_process_echo(to_stdin, from_stdout):
""")

def test_echo(self):
"""Echo terminal input, and translate the echoed newline."""
# Echo terminal input, and translate the echoed newline.
child_code = self._EXEC_IMPORTS + \
self._EXEC_BASE_TERMINAL_SETUP_FMT.format(add_lflags="") + \
self._EXEC_CHILD_ECHO
Expand Down Expand Up @@ -739,8 +734,7 @@ def _background_process_bell(to_stdin, from_stdout):
""")

def test_bell_echoctl(self):
"""Terminals: Pretty printing of the bell character in caret
notation."""
# Pretty printing of the bell character in caret notation.
lflags = self._enable_echoctl()
child_code = self._EXEC_IMPORTS + \
self._EXEC_BASE_TERMINAL_SETUP_FMT.format(add_lflags=lflags) + \
Expand Down Expand Up @@ -786,7 +780,7 @@ def _background_process_eof(to_stdin, from_stdout):
""")

def test_eof(self):
"""Terminals: Processing of the special EOF character."""
# Processing of the special EOF character.
child_code = self._EXEC_IMPORTS + \
self._EXEC_BASE_TERMINAL_SETUP_FMT.format(add_lflags="") + \
self._EXEC_CHILD_EOF
Expand Down Expand Up @@ -843,10 +837,10 @@ def _SIGINT_handler(a, b):
""")

def test_intr(self):
"""Terminals: Writing a x03 char to the master side is
translated to sending an INTR signal to the slave. Simulates
pressing ctrl+c in master."""
# tell our controlling terminal to send signals on special characters
# Writing a x03 char to the master side is translated to sending
# an INTR signal to the slave. Simulates pressing ctrl+c in
# master.
# Tell our controlling terminal to send signals on special characters
lflags = " | termios.ISIG"
child_code = self._EXEC_IMPORTS + \
self._EXEC_BASE_TERMINAL_SETUP_FMT.format(add_lflags=lflags) + \
Expand Down Expand Up @@ -927,7 +921,7 @@ def test__mock_stdin_stdout(self):
self.assertGreater(pty.STDIN_FILENO, 2, "replaced by our mock")

def test__mock_select(self):
"""Test the select proxy of this test class. Meta testing."""
# Test the select proxy of this test class. Meta testing.
self.select_rfds_lengths.append(0)
with self.assertRaises(AssertionError):
self._mock_select([], [], [])
Expand Down Expand Up @@ -956,7 +950,7 @@ def _socketpair(self):
return socketpair

def test__copy_to_each(self):
"""Test the normal data case on both master_fd and stdin."""
# Test the normal data case on both master_fd and stdin.
masters = [s.fileno() for s in self._socketpair()]

# Feed data. Smaller than PIPEBUF. These writes will not block.
Expand Down Expand Up @@ -1024,15 +1018,15 @@ def _copy_eof_close_slave_helper(self, close_stdin):
self.assertEqual(unconsumed, b'from stdin')

def test__copy_eof_on_all(self):
"""Test the empty read EOF case on both master_fd and stdin."""
# Test the empty read EOF case on both master_fd and stdin.
self._copy_eof_close_slave_helper(close_stdin=True)

def test__copy_eof_on_master(self):
"""Test the empty read EOF case on only master_fd."""
# Test the empty read EOF case on only master_fd.
self._copy_eof_close_slave_helper(close_stdin=False)

def test__copy_eof_on_stdin(self):
"""Test the empty read EOF case on stdin."""
# Test the empty read EOF case on stdin.
masters = [s.fileno() for s in self._socketpair()]

# Fill with dummy data
Expand Down