diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-07-07 22:01:28 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-07-07 22:01:28 (GMT) |
commit | e8209dab6b28638bc5b7afd361f797ab302ac898 (patch) | |
tree | d0cf87542f639168643166aa8328756c7dbd2506 /Lib/test/test_asynchat.py | |
parent | ac7d80c7d040936ee90e6d62058493727caa7611 (diff) | |
parent | d9e810a8701b92371232eece5896a799c33de505 (diff) | |
download | cpython-e8209dab6b28638bc5b7afd361f797ab302ac898.zip cpython-e8209dab6b28638bc5b7afd361f797ab302ac898.tar.gz cpython-e8209dab6b28638bc5b7afd361f797ab302ac898.tar.bz2 |
(Merge 3.4) Issue #12523: asynchat.async_chat.push() now raises a TypeError if
it doesn't get a bytes string
Diffstat (limited to 'Lib/test/test_asynchat.py')
-rw-r--r-- | Lib/test/test_asynchat.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_asynchat.py b/Lib/test/test_asynchat.py index 55e0d2a..23944d7 100644 --- a/Lib/test/test_asynchat.py +++ b/Lib/test/test_asynchat.py @@ -250,6 +250,22 @@ class TestAsynchat(unittest.TestCase): # (which could still result in the client not having received anything) self.assertGreater(len(s.buffer), 0) + def test_push(self): + # Issue #12523: push() should raise a TypeError if it doesn't get + # a bytes string + s, event = start_echo_server() + c = echo_client(b'\n', s.port) + data = b'bytes\n' + c.push(data) + c.push(bytearray(data)) + c.push(memoryview(data)) + self.assertRaises(TypeError, c.push, 10) + self.assertRaises(TypeError, c.push, 'unicode') + c.push(SERVER_QUIT) + asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01) + s.join(timeout=TIMEOUT) + self.assertEqual(c.contents, [b'bytes', b'bytes', b'bytes']) + class TestAsynchat_WithPoll(TestAsynchat): usepoll = True |