Back to index

python3.2  3.2.2
Public Member Functions
test.test_asyncore.DispatcherTests Class Reference

List of all members.

Public Member Functions

def setUp
def tearDown
def test_basic
def test_repr
def test_log
def test_log_info
def test_unhandled
def test_issue_8594
def test_strerror

Detailed Description

Definition at line 230 of file test_asyncore.py.


Member Function Documentation

Definition at line 231 of file test_asyncore.py.

00231 
00232     def setUp(self):
00233         pass

Here is the caller graph for this function:

Definition at line 234 of file test_asyncore.py.

00234 
00235     def tearDown(self):
00236         asyncore.close_all()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 237 of file test_asyncore.py.

00237 
00238     def test_basic(self):
00239         d = asyncore.dispatcher()
00240         self.assertEqual(d.readable(), True)
00241         self.assertEqual(d.writable(), True)

Here is the call graph for this function:

Definition at line 309 of file test_asyncore.py.

00309 
00310     def test_issue_8594(self):
00311         # XXX - this test is supposed to be removed in next major Python
00312         # version
00313         d = asyncore.dispatcher(socket.socket())
00314         # make sure the error message no longer refers to the socket
00315         # object but the dispatcher instance instead
00316         self.assertRaisesRegex(AttributeError, 'dispatcher instance',
00317                                getattr, d, 'foo')
00318         # cheap inheritance with the underlying socket is supposed
00319         # to still work but a DeprecationWarning is expected
00320         with warnings.catch_warnings(record=True) as w:
00321             warnings.simplefilter("always")
00322             family = d.family
00323             self.assertEqual(family, socket.AF_INET)
00324             self.assertEqual(len(w), 1)
00325             self.assertTrue(issubclass(w[0].category, DeprecationWarning))

Here is the call graph for this function:

Definition at line 246 of file test_asyncore.py.

00246 
00247     def test_log(self):
00248         d = asyncore.dispatcher()
00249 
00250         # capture output of dispatcher.log() (to stderr)
00251         fp = StringIO()
00252         stderr = sys.stderr
00253         l1 = "Lovely spam! Wonderful spam!"
00254         l2 = "I don't like spam!"
00255         try:
00256             sys.stderr = fp
00257             d.log(l1)
00258             d.log(l2)
00259         finally:
00260             sys.stderr = stderr
00261 
00262         lines = fp.getvalue().splitlines()
00263         self.assertEqual(lines, ['log: %s' % l1, 'log: %s' % l2])

Here is the call graph for this function:

Definition at line 264 of file test_asyncore.py.

00264 
00265     def test_log_info(self):
00266         d = asyncore.dispatcher()
00267 
00268         # capture output of dispatcher.log_info() (to stdout via print)
00269         fp = StringIO()
00270         stdout = sys.stdout
00271         l1 = "Have you got anything without spam?"
00272         l2 = "Why can't she have egg bacon spam and sausage?"
00273         l3 = "THAT'S got spam in it!"
00274         try:
00275             sys.stdout = fp
00276             d.log_info(l1, 'EGGS')
00277             d.log_info(l2)
00278             d.log_info(l3, 'SPAM')
00279         finally:
00280             sys.stdout = stdout
00281 
00282         lines = fp.getvalue().splitlines()
00283         expected = ['EGGS: %s' % l1, 'info: %s' % l2, 'SPAM: %s' % l3]
00284 
00285         self.assertEqual(lines, expected)

Here is the call graph for this function:

Definition at line 242 of file test_asyncore.py.

00242 
00243     def test_repr(self):
00244         d = asyncore.dispatcher()
00245         self.assertEqual(repr(d), '<asyncore.dispatcher at %#x>' % id(d))

Here is the call graph for this function:

Definition at line 326 of file test_asyncore.py.

00326 
00327     def test_strerror(self):
00328         # refers to bug #8573
00329         err = asyncore._strerror(errno.EPERM)
00330         if hasattr(os, 'strerror'):
00331             self.assertEqual(err, os.strerror(errno.EPERM))
00332         err = asyncore._strerror(-1)
00333         self.assertTrue(err != "")
00334 

Here is the call graph for this function:

Definition at line 286 of file test_asyncore.py.

00286 
00287     def test_unhandled(self):
00288         d = asyncore.dispatcher()
00289         d.ignore_log_types = ()
00290 
00291         # capture output of dispatcher.log_info() (to stdout via print)
00292         fp = StringIO()
00293         stdout = sys.stdout
00294         try:
00295             sys.stdout = fp
00296             d.handle_expt()
00297             d.handle_read()
00298             d.handle_write()
00299             d.handle_connect()
00300         finally:
00301             sys.stdout = stdout
00302 
00303         lines = fp.getvalue().splitlines()
00304         expected = ['warning: unhandled incoming priority event',
00305                     'warning: unhandled read event',
00306                     'warning: unhandled write event',
00307                     'warning: unhandled connect event']
00308         self.assertEqual(lines, expected)

Here is the call graph for this function:


The documentation for this class was generated from the following file: