MCPcopy Index your code
hub / github.com/python/cpython / test_cgi_xmlrpc_response

Method test_cgi_xmlrpc_response

Lib/test/test_xmlrpc.py:1458–1498  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1456
1457
1458 def test_cgi_xmlrpc_response(self):
1459 data = """<?xml version='1.0'?>
1460 <methodCall>
1461 <methodName>test_method</methodName>
1462 <params>
1463 <param>
1464 <value><string>foo</string></value>
1465 </param>
1466 <param>
1467 <value><string>bar</string></value>
1468 </param>
1469 </params>
1470 </methodCall>
1471 """
1472
1473 with os_helper.EnvironmentVarGuard() as env, \
1474 captured_stdout(encoding=self.cgi.encoding) as data_out, \
1475 support.captured_stdin() as data_in:
1476 data_in.write(data)
1477 data_in.seek(0)
1478 env['CONTENT_LENGTH'] = str(len(data))
1479 self.cgi.handle_request()
1480 data_out.seek(0)
1481
1482 # will respond exception, if so, our goal is achieved ;)
1483 handle = data_out.read()
1484
1485 # start with 44th char so as not to get http header, we just
1486 # need only xml
1487 self.assertRaises(xmlrpclib.Fault, xmlrpclib.loads, handle[44:])
1488
1489 # Also test the content-length returned by handle_request
1490 # Using the same test method inorder to avoid all the datapassing
1491 # boilerplate code.
1492 # Test for bug: http://bugs.python.org/issue5040
1493
1494 content = handle[handle.find("<?xml"):]
1495
1496 self.assertEqual(
1497 int(re.search(r'Content-Length: (\d+)', handle).group(1)),
1498 len(content))
1499
1500
1501class UseBuiltinTypesTestCase(unittest.TestCase):

Callers

nothing calls this directly

Calls 11

strFunction · 0.85
captured_stdoutFunction · 0.70
writeMethod · 0.45
seekMethod · 0.45
handle_requestMethod · 0.45
readMethod · 0.45
assertRaisesMethod · 0.45
findMethod · 0.45
assertEqualMethod · 0.45
groupMethod · 0.45
searchMethod · 0.45

Tested by

no test coverage detected