(self)
| 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 | |
| 1501 | class UseBuiltinTypesTestCase(unittest.TestCase): |
nothing calls this directly
no test coverage detected