Skip to content

Commit 333a761

Browse files
committed
split stdout and stderr, remove output check after self.assertRaises(SystemExit)
1 parent 05aea06 commit 333a761

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

Lib/test/test_httpservers.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,11 +1569,12 @@ def setUp(self):
15691569
self.addCleanup(os_helper.unlink, self.tls_password_file)
15701570

15711571
def invoke_httpd(self, *args):
1572-
output = StringIO()
1573-
with contextlib.redirect_stdout(output), \
1574-
contextlib.redirect_stderr(output):
1572+
stdout = StringIO()
1573+
stderr = StringIO()
1574+
with contextlib.redirect_stdout(stdout), \
1575+
contextlib.redirect_stderr(stderr):
15751576
server._main(args)
1576-
return output.getvalue()
1577+
return {'stdout': stdout.getvalue(), 'stderr': stderr.getvalue()}
15771578

15781579
@mock.patch('http.server.test')
15791580
def test_port_flag(self, mock_func):
@@ -1703,14 +1704,11 @@ def test_help_flag(self, _):
17031704
for option in options:
17041705
with self.assertRaises(SystemExit):
17051706
output = self.invoke_httpd(option)
1706-
self.assertStartsWith(output, 'usage: ')
17071707

17081708
@mock.patch('http.server.test')
17091709
def test_unknown_flag(self, _):
17101710
with self.assertRaises(SystemExit):
17111711
output = self.invoke_httpd('--unknown-flag')
1712-
self.assertStartsWith(output, 'usage: ')
1713-
17141712

17151713
class CommandLineRunTimeTestCase(unittest.TestCase):
17161714
random_data = os.urandom(1024)

0 commit comments

Comments
 (0)