summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2014-12-06 01:34:56 (GMT)
committerBenjamin Peterson <benjamin@python.org>2014-12-06 01:34:56 (GMT)
commiteca72d47f5a639a0ac66a98a2d63b30df2ce310f (patch)
tree5c67eee0bab41a933c82c1d0d2540e4215cad215 /Lib/test
parentf990e7f1f0de45a07bab0e520d01f706b6f46569 (diff)
parent81b7374fbe5f77567642d5aa42d4c1e6eee610b2 (diff)
downloadcpython-eca72d47f5a639a0ac66a98a2d63b30df2ce310f.zip
cpython-eca72d47f5a639a0ac66a98a2d63b30df2ce310f.tar.gz
cpython-eca72d47f5a639a0ac66a98a2d63b30df2ce310f.tar.bz2
merge 3.3 (#16043)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_xmlrpc.py25
1 files changed, 23 insertions, 2 deletions
diff --git a/Lib/test/test_xmlrpc.py b/Lib/test/test_xmlrpc.py
index 9194740..71b590c 100644
--- a/Lib/test/test_xmlrpc.py
+++ b/Lib/test/test_xmlrpc.py
@@ -863,7 +863,7 @@ class GzipServerTestCase(BaseServerTestCase):
p.pow(6, 8)
p("close")()
- def test_gsip_response(self):
+ def test_gzip_response(self):
t = self.Transport()
p = xmlrpclib.ServerProxy(URL, transport=t)
old = self.requestHandler.encode_threshold
@@ -877,6 +877,27 @@ class GzipServerTestCase(BaseServerTestCase):
self.requestHandler.encode_threshold = old
self.assertTrue(a>b)
+
+@unittest.skipIf(gzip is None, 'requires gzip')
+class GzipUtilTestCase(unittest.TestCase):
+
+ def test_gzip_decode_limit(self):
+ max_gzip_decode = 20 * 1024 * 1024
+ data = b'\0' * max_gzip_decode
+ encoded = xmlrpclib.gzip_encode(data)
+ decoded = xmlrpclib.gzip_decode(encoded)
+ self.assertEqual(len(decoded), max_gzip_decode)
+
+ data = b'\0' * (max_gzip_decode + 1)
+ encoded = xmlrpclib.gzip_encode(data)
+
+ with self.assertRaisesRegexp(ValueError,
+ "max gzipped payload length exceeded"):
+ xmlrpclib.gzip_decode(encoded)
+
+ xmlrpclib.gzip_decode(encoded, max_decode=-1)
+
+
#Test special attributes of the ServerProxy object
class ServerProxyTestCase(unittest.TestCase):
def setUp(self):
@@ -1105,7 +1126,7 @@ def test_main():
support.run_unittest(XMLRPCTestCase, HelperTestCase, DateTimeTestCase,
BinaryTestCase, FaultTestCase, UseBuiltinTypesTestCase,
SimpleServerTestCase, KeepaliveServerTestCase1,
- KeepaliveServerTestCase2, GzipServerTestCase,
+ KeepaliveServerTestCase2, GzipServerTestCase, GzipUtilTestCase,
MultiPathServerTestCase, ServerProxyTestCase, FailingServerTestCase,
CGIHandlerTestCase)