mirror of
https://github.com/python/cpython.git
synced 2025-10-09 08:31:26 +00:00
#10695: use %s not %d so that a string 'port' does not cause a debug traceback
Passing the port as a string value works fine in regular mode, but if you turned debug on it would throw an error trying to print the port number, which is surprising and confusing.
This commit is contained in:
parent
8edd99d085
commit
32ef70c827
3 changed files with 14 additions and 1 deletions
|
@ -342,6 +342,16 @@ class OptionTests(TestCase):
|
|||
expected = "send b'xxx'\n"
|
||||
self.assertIn(expected, telnet._messages)
|
||||
|
||||
def test_debug_accepts_str_port(self):
|
||||
# Issue 10695
|
||||
with test_socket([]):
|
||||
telnet = TelnetAlike('dummy', '0')
|
||||
telnet._messages = ''
|
||||
telnet.set_debuglevel(1)
|
||||
telnet.msg('test')
|
||||
self.assertRegex(telnet._messages, r'0.*test')
|
||||
|
||||
|
||||
def test_main(verbose=None):
|
||||
support.run_unittest(GeneralTests, ReadTests, WriteTests, OptionTests)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue