Back to index

python3.2  3.2.2
Public Member Functions | Static Public Attributes
test.test_imaplib.ThreadedNetworkedTests Class Reference
Inheritance diagram for test.test_imaplib.ThreadedNetworkedTests:
Inheritance graph
[legend]
Collaboration diagram for test.test_imaplib.ThreadedNetworkedTests:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def make_server
def reap_server
def reaped_server
def test_connect
def test_issue5949
def test_line_termination

Static Public Attributes

 server_class = socketserver.TCPServer
 imap_class = imaplib.IMAP4

Detailed Description

Definition at line 196 of file test_imaplib.py.


Member Function Documentation

def test.test_imaplib.BaseThreadedNetworkedTests.make_server (   self,
  addr,
  hdlr 
) [inherited]

Definition at line 118 of file test_imaplib.py.

00118 
00119     def make_server(self, addr, hdlr):
00120 
00121         class MyServer(self.server_class):
00122             def handle_error(self, request, client_address):
00123                 self.close_request(request)
00124                 self.server_close()
00125                 raise
00126 
00127         if verbose: print("creating server")
00128         server = MyServer(addr, hdlr)
00129         self.assertEqual(server.server_address, server.socket.getsockname())
00130 
00131         if verbose:
00132             print("server created")
00133             print("ADDR =", addr)
00134             print("CLASS =", self.server_class)
00135             print("HDLR =", server.RequestHandlerClass)
00136 
00137         t = threading.Thread(
00138             name='%s serving' % self.server_class,
00139             target=server.serve_forever,
00140             # Short poll interval to make the test finish quickly.
00141             # Time between requests is short enough that we won't wake
00142             # up spuriously too many times.
00143             kwargs={'poll_interval':0.01})
00144         t.daemon = True  # In case this function raises.
00145         t.start()
00146         if verbose: print("server running")
00147         return server, t

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_imaplib.BaseThreadedNetworkedTests.reap_server (   self,
  server,
  thread 
) [inherited]

Definition at line 148 of file test_imaplib.py.

00148 
00149     def reap_server(self, server, thread):
00150         if verbose: print("waiting for server")
00151         server.shutdown()
00152         server.server_close()
00153         thread.join()
00154         if verbose: print("done")

Here is the caller graph for this function:

def test.test_imaplib.BaseThreadedNetworkedTests.reaped_server (   self,
  hdlr 
) [inherited]

Definition at line 156 of file test_imaplib.py.

00156 
00157     def reaped_server(self, hdlr):
00158         server, thread = self.make_server((support.HOST, 0), hdlr)
00159         try:
00160             yield server
00161         finally:
00162             self.reap_server(server, thread)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 164 of file test_imaplib.py.

00164 
00165     def test_connect(self):
00166         with self.reaped_server(SimpleIMAPHandler) as server:
00167             client = self.imap_class(*server.server_address)
00168             client.shutdown()

Here is the call graph for this function:

Definition at line 170 of file test_imaplib.py.

00170 
00171     def test_issue5949(self):
00172 
00173         class EOFHandler(socketserver.StreamRequestHandler):
00174             def handle(self):
00175                 # EOF without sending a complete welcome message.
00176                 self.wfile.write(b'* OK')
00177 
00178         with self.reaped_server(EOFHandler) as server:
00179             self.assertRaises(imaplib.IMAP4.abort,
00180                               self.imap_class, *server.server_address)

Here is the call graph for this function:

Definition at line 182 of file test_imaplib.py.

00182 
00183     def test_line_termination(self):
00184 
00185         class BadNewlineHandler(SimpleIMAPHandler):
00186 
00187             def cmd_CAPABILITY(self, tag, args):
00188                 self._send(b'* CAPABILITY IMAP4rev1 AUTH\n')
00189                 self._send('{} OK CAPABILITY completed\r\n'.format(tag).encode('ASCII'))
00190 
00191         with self.reaped_server(BadNewlineHandler) as server:
00192             self.assertRaises(imaplib.IMAP4.abort,
00193                               self.imap_class, *server.server_address)
00194 
00195 

Here is the call graph for this function:


Member Data Documentation

Definition at line 199 of file test_imaplib.py.

Definition at line 198 of file test_imaplib.py.


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