Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
test.test_asyncore.FileWrapperTest Class Reference

List of all members.

Public Member Functions

def setUp
def tearDown
def test_recv
def test_send
def test_dispatcher

Public Attributes

 d

Detailed Description

Definition at line 397 of file test_asyncore.py.


Member Function Documentation

Definition at line 398 of file test_asyncore.py.

00398 
00399     def setUp(self):
00400         self.d = b"It's not dead, it's sleeping!"
00401         with open(TESTFN, 'wb') as file:
00402             file.write(self.d)

Here is the caller graph for this function:

Definition at line 403 of file test_asyncore.py.

00403 
00404     def tearDown(self):
00405         unlink(TESTFN)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 433 of file test_asyncore.py.

00433 
00434     def test_dispatcher(self):
00435         fd = os.open(TESTFN, os.O_RDONLY)
00436         data = []
00437         class FileDispatcher(asyncore.file_dispatcher):
00438             def handle_read(self):
00439                 data.append(self.recv(29))
00440         s = FileDispatcher(fd)
00441         os.close(fd)
00442         asyncore.loop(timeout=0.01, use_poll=True, count=2)
00443         self.assertEqual(b"".join(data), self.d)
00444 

Here is the call graph for this function:

Definition at line 406 of file test_asyncore.py.

00406 
00407     def test_recv(self):
00408         fd = os.open(TESTFN, os.O_RDONLY)
00409         w = asyncore.file_wrapper(fd)
00410         os.close(fd)
00411 
00412         self.assertNotEqual(w.fd, fd)
00413         self.assertNotEqual(w.fileno(), fd)
00414         self.assertEqual(w.recv(13), b"It's not dead")
00415         self.assertEqual(w.read(6), b", it's")
00416         w.close()
00417         self.assertRaises(OSError, w.read, 1)

Here is the call graph for this function:

Definition at line 418 of file test_asyncore.py.

00418 
00419     def test_send(self):
00420         d1 = b"Come again?"
00421         d2 = b"I want to buy some cheese."
00422         fd = os.open(TESTFN, os.O_WRONLY | os.O_APPEND)
00423         w = asyncore.file_wrapper(fd)
00424         os.close(fd)
00425 
00426         w.write(d1)
00427         w.send(d2)
00428         w.close()
00429         with open(TESTFN, 'rb') as file:
00430             self.assertEqual(file.read(), self.d + d1 + d2)

Here is the call graph for this function:


Member Data Documentation

Definition at line 399 of file test_asyncore.py.


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