Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
test.test_xmlrpc.FailingServerTestCase Class Reference

List of all members.

Public Member Functions

def setUp
def tearDown
def test_basic
def test_fail_no_info
def test_fail_with_info

Public Attributes

 evt

Detailed Description

Definition at line 776 of file test_xmlrpc.py.


Member Function Documentation

Definition at line 777 of file test_xmlrpc.py.

00777 
00778     def setUp(self):
00779         self.evt = threading.Event()
00780         # start server thread to handle requests
00781         serv_args = (self.evt, 1)
00782         threading.Thread(target=http_server, args=serv_args).start()
00783 
00784         # wait for the server to be ready
00785         self.evt.wait()
00786         self.evt.clear()

Here is the caller graph for this function:

Definition at line 787 of file test_xmlrpc.py.

00787 
00788     def tearDown(self):
00789         # wait on the server thread to terminate
00790         self.evt.wait()
00791         # reset flag
00792         xmlrpc.server.SimpleXMLRPCServer._send_traceback_header = False
00793         # reset message class
00794         default_class = http.client.HTTPMessage
00795         xmlrpc.server.SimpleXMLRPCRequestHandler.MessageClass = default_class

Here is the caller graph for this function:

Definition at line 796 of file test_xmlrpc.py.

00796 
00797     def test_basic(self):
00798         # check that flag is false by default
00799         flagval = xmlrpc.server.SimpleXMLRPCServer._send_traceback_header
00800         self.assertEqual(flagval, False)
00801 
00802         # enable traceback reporting
00803         xmlrpc.server.SimpleXMLRPCServer._send_traceback_header = True
00804 
00805         # test a call that shouldn't fail just as a smoke test
00806         try:
00807             p = xmlrpclib.ServerProxy(URL)
00808             self.assertEqual(p.pow(6,8), 6**8)
00809         except (xmlrpclib.ProtocolError, socket.error) as e:
00810             # ignore failures due to non-blocking socket 'unavailable' errors
00811             if not is_unavailable_exception(e):
00812                 # protocol error; provide additional information in test output
00813                 self.fail("%s\n%s" % (e, getattr(e, "headers", "")))

Here is the call graph for this function:

Definition at line 814 of file test_xmlrpc.py.

00814 
00815     def test_fail_no_info(self):
00816         # use the broken message class
00817         xmlrpc.server.SimpleXMLRPCRequestHandler.MessageClass = FailingMessageClass
00818 
00819         try:
00820             p = xmlrpclib.ServerProxy(URL)
00821             p.pow(6,8)
00822         except (xmlrpclib.ProtocolError, socket.error) as e:
00823             # ignore failures due to non-blocking socket 'unavailable' errors
00824             if not is_unavailable_exception(e) and hasattr(e, "headers"):
00825                 # The two server-side error headers shouldn't be sent back in this case
00826                 self.assertTrue(e.headers.get("X-exception") is None)
00827                 self.assertTrue(e.headers.get("X-traceback") is None)
00828         else:
00829             self.fail('ProtocolError not raised')

Here is the call graph for this function:

Definition at line 830 of file test_xmlrpc.py.

00830 
00831     def test_fail_with_info(self):
00832         # use the broken message class
00833         xmlrpc.server.SimpleXMLRPCRequestHandler.MessageClass = FailingMessageClass
00834 
00835         # Check that errors in the server send back exception/traceback
00836         # info when flag is set
00837         xmlrpc.server.SimpleXMLRPCServer._send_traceback_header = True
00838 
00839         try:
00840             p = xmlrpclib.ServerProxy(URL)
00841             p.pow(6,8)
00842         except (xmlrpclib.ProtocolError, socket.error) as e:
00843             # ignore failures due to non-blocking socket 'unavailable' errors
00844             if not is_unavailable_exception(e) and hasattr(e, "headers"):
00845                 # We should get error info in the response
00846                 expected_err = "invalid literal for int() with base 10: 'I am broken'"
00847                 self.assertEqual(e.headers.get("X-exception"), expected_err)
00848                 self.assertTrue(e.headers.get("X-traceback") is not None)
00849         else:
00850             self.fail('ProtocolError not raised')
00851 
00852 
@contextlib.contextmanager

Here is the call graph for this function:


Member Data Documentation

Definition at line 778 of file test_xmlrpc.py.


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