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