diff options
Diffstat (limited to 'Lib/test/test_docxmlrpc.py')
| -rw-r--r-- | Lib/test/test_docxmlrpc.py | 87 |
1 files changed, 42 insertions, 45 deletions
diff --git a/Lib/test/test_docxmlrpc.py b/Lib/test/test_docxmlrpc.py index 80d1803..d6ca458 100644 --- a/Lib/test/test_docxmlrpc.py +++ b/Lib/test/test_docxmlrpc.py @@ -1,8 +1,8 @@ -from DocXMLRPCServer import DocXMLRPCServer -import httplib +from xmlrpc.server import DocXMLRPCServer +import http.client import sys -from test import test_support -threading = test_support.import_module('threading') +from test import support +threading = support.import_module('threading') import time import socket import unittest @@ -69,7 +69,7 @@ def server(evt, numrequests): class DocXMLRPCHTTPGETServer(unittest.TestCase): def setUp(self): - self._threads = test_support.threading_setup() + self._threads = support.threading_setup() # Enable server feedback DocXMLRPCServer._send_traceback_header = True @@ -82,7 +82,7 @@ class DocXMLRPCHTTPGETServer(unittest.TestCase): time.sleep(0.001) n -= 1 - self.client = httplib.HTTPConnection("localhost:%d" % PORT) + self.client = http.client.HTTPConnection("localhost:%d" % PORT) def tearDown(self): self.client.close() @@ -91,7 +91,7 @@ class DocXMLRPCHTTPGETServer(unittest.TestCase): # Disable server feedback DocXMLRPCServer._send_traceback_header = False - test_support.threading_cleanup(*self._threads) + support.threading_cleanup(*self._threads) def test_valid_get_response(self): self.client.request("GET", "/") @@ -122,8 +122,8 @@ class DocXMLRPCHTTPGETServer(unittest.TestCase): self.client.request("GET", "/") response = self.client.getresponse() - self.assertIn('<dl><dt><a name="-<lambda>"><strong>' - '<lambda></strong></a>(x, y)</dt></dl>', + self.assertIn((b'<dl><dt><a name="-<lambda>"><strong>' + b'<lambda></strong></a>(x, y)</dt></dl>'), response.read()) @make_request_and_skipIf(sys.flags.optimize >= 2, @@ -136,19 +136,19 @@ class DocXMLRPCHTTPGETServer(unittest.TestCase): The documentation for the "add" method contains the test material. """ self.client.request("GET", "/") - response = self.client.getresponse() + response = self.client.getresponse().read() self.assertIn( - ('<dl><dt><a name="-add"><strong>add</strong></a>(x, y)</dt><dd>' - '<tt>Add two instances together. This ' - 'follows <a href="http://www.python.org/dev/peps/pep-0008/">' - 'PEP008</a>, but has nothing<br>\nto do ' - 'with <a href="http://www.rfc-editor.org/rfc/rfc1952.txt">' - 'RFC1952</a>. Case should matter: pEp008 ' - 'and rFC1952. Things<br>\nthat start ' - 'with http and ftp should be ' - 'auto-linked, too:<br>\n<a href="http://google.com">' - 'http://google.com</a>.</tt></dd></dl>'), response.read()) + (b'<dl><dt><a name="-add"><strong>add</strong></a>(x, y)</dt><dd>' + b'<tt>Add two instances together. This ' + b'follows <a href="http://www.python.org/dev/peps/pep-0008/">' + b'PEP008</a>, but has nothing<br>\nto do ' + b'with <a href="http://www.rfc-editor.org/rfc/rfc1952.txt">' + b'RFC1952</a>. Case should matter: pEp008 ' + b'and rFC1952. Things<br>\nthat start ' + b'with http and ftp should be ' + b'auto-linked, too:<br>\n<a href="http://google.com">' + b'http://google.com</a>.</tt></dd></dl>'), response) @make_request_and_skipIf(sys.flags.optimize >= 2, "Docstrings are omitted with -O2 and above") @@ -159,31 +159,28 @@ class DocXMLRPCHTTPGETServer(unittest.TestCase): systems related to that process. """ self.client.request("GET", "/") - response = self.client.getresponse() + response = self.client.getresponse().read() self.assertIn( - ('<dl><dt><a name="-system.listMethods"><strong>system.listMethods' - '</strong></a>()</dt><dd><tt><a href="#-system.listMethods">system' - '.listMethods</a>() => [\'add\', \'subtract\',' - ' \'multiple\']<br>\n <br>\nReturns a list' - ' of the methods supported by the' - ' server.</tt></dd></dl>\n <dl><dt><a name="-system.methodHelp">' - '<strong>system.methodHelp</strong></a>(method_name)</dt><dd><tt>' - '<a href="#-system.methodHelp">system.methodHelp</a>(\'add\') ' - '=> "Adds two integers together"<br>\n ' - '<br>\nReturns a string containing documentation' - ' for the specified method.</tt></dd></dl>\n ' - '<dl><dt><a name="-system.methodSignature"><strong>system.' - 'methodSignature</strong></a>(method_name)</dt><dd><tt><a href="#-' - 'system.methodSignature">system.methodSignature</a>(\'add\') ' - '=> [double, int, int]<br>\n <br>\nReturns' - ' a list describing the signature of' - ' the method. In the<br>\nabove example,' - ' the add method takes two integers' - ' as arguments<br>\nand returns a double' - ' result.<br>\n <br>\nThis server does ' - 'NOT support system.methodSignature.</tt></dd></dl>'), - response.read()) + (b'<dl><dt><a name="-system.methodHelp"><strong>system.methodHelp' + b'</strong></a>(method_name)</dt><dd><tt><a href="#-system.method' + b'Help">system.methodHelp</a>(\'add\') => "Adds ' + b'two integers together"<br>\n <br>\nReturns a' + b' string containing documentation for ' + b'the specified method.</tt></dd></dl>\n<dl><dt><a name' + b'="-system.methodSignature"><strong>system.methodSignature</strong>' + b'</a>(method_name)</dt><dd><tt><a href="#-system.methodSignature">' + b'system.methodSignature</a>(\'add\') => [double, ' + b'int, int]<br>\n <br>\nReturns a list ' + b'describing the signature of the method.' + b' In the<br>\nabove example, the add ' + b'method takes two integers as arguments' + b'<br>\nand returns a double result.<br>\n ' + b'<br>\nThis server does NOT support system' + b'.methodSignature.</tt></dd></dl>\n<dl><dt><a name="-test_method">' + b'<strong>test_method</strong></a>(arg)</dt><dd><tt>Test ' + b'method\'s docs. This method truly does' + b' very little.</tt></dd></dl>'), response) def test_autolink_dotted_methods(self): """Test that selfdot values are made strong automatically in the @@ -191,11 +188,11 @@ class DocXMLRPCHTTPGETServer(unittest.TestCase): self.client.request("GET", "/") response = self.client.getresponse() - self.assertIn("""Try self.<strong>add</strong>, too.""", + self.assertIn(b"""Try self.<strong>add</strong>, too.""", response.read()) def test_main(): - test_support.run_unittest(DocXMLRPCHTTPGETServer) + support.run_unittest(DocXMLRPCHTTPGETServer) if __name__ == '__main__': test_main() |
