diff options
author | Giampaolo RodolĂ <g.rodola@gmail.com> | 2010-05-06 17:57:06 (GMT) |
---|---|---|
committer | Giampaolo RodolĂ <g.rodola@gmail.com> | 2010-05-06 17:57:06 (GMT) |
commit | f7454fa98dfe5d2c3d59437aade27b5daa6208c5 (patch) | |
tree | d87578596420ca2799f21eb387d0cbb9f0db4de5 /Lib/test/test_asyncore.py | |
parent | a8ac944924281a2604c1a3329465705fe30bab68 (diff) | |
download | cpython-f7454fa98dfe5d2c3d59437aade27b5daa6208c5.zip cpython-f7454fa98dfe5d2c3d59437aade27b5daa6208c5.tar.gz cpython-f7454fa98dfe5d2c3d59437aade27b5daa6208c5.tar.bz2 |
Fix asyncore issues 8573 and 8483: _strerror might throw ValueError; asyncore.__getattr__ cheap inheritance caused confusing error messages when accessing undefined class attributes; added an alias for __str__ which now is used as a fallback for __repr__
Diffstat (limited to 'Lib/test/test_asyncore.py')
-rw-r--r-- | Lib/test/test_asyncore.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_asyncore.py b/Lib/test/test_asyncore.py index 0cf14bf..bc2dd72 100644 --- a/Lib/test/test_asyncore.py +++ b/Lib/test/test_asyncore.py @@ -5,6 +5,7 @@ import os import socket import sys import time +import warnings from test import test_support from test.test_support import TESTFN, run_unittest, unlink @@ -305,6 +306,22 @@ class DispatcherTests(unittest.TestCase): 'warning: unhandled accept event'] self.assertEquals(lines, expected) + def test_issue_8594(self): + # XXX - this test is supposed to be removed in next major Python + # version + d = asyncore.dispatcher(socket.socket()) + # make sure the error message no longer refers to the socket + # object but the dispatcher instance instead + self.assertRaisesRegexp(AttributeError, 'dispatcher instance', + getattr, d, 'foo') + # cheap inheritance with the underlying socket is supposed + # to still work but a DeprecationWarning is expected + with warnings.catch_warnings(record=True) as w: + warnings.simplefilter("always") + family = d.family + self.assertEqual(family, socket.AF_INET) + self.assertTrue(len(w) == 1) + self.assertTrue(issubclass(w[0].category, DeprecationWarning)) class dispatcherwithsend_noread(asyncore.dispatcher_with_send): |