summaryrefslogtreecommitdiff
path: root/cherrypy/test/test_http.py
diff options
context:
space:
mode:
authorSviatoslav Sydorenko <ssydore@softserveinc.com>2016-08-25 18:32:35 +0300
committerSviatoslav Sydorenko <ssydore@softserveinc.com>2016-08-25 18:32:35 +0300
commita6872380d8a946673783041299007431b93d2392 (patch)
tree282b2032c78bd657f44adcd8357bb4c030505b1e /cherrypy/test/test_http.py
parentef76fb3760c4f1dfa72d1d1195f9792a8e46d22d (diff)
downloadcherrypy-git-a6872380d8a946673783041299007431b93d2392.tar.gz
Fix test_http:HTTPTests.test_no_content_length
Fixes Travis CI build failing under nightly 3.6-dev: - http.client.HTTPConnection now has _get_content_length static method instead of _set_content_length. Mocked both regardless of Python runtime version - Added 3.6 env to tox config
Diffstat (limited to 'cherrypy/test/test_http.py')
-rw-r--r--cherrypy/test/test_http.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/cherrypy/test/test_http.py b/cherrypy/test/test_http.py
index f918ebc9..48b60811 100644
--- a/cherrypy/test/test_http.py
+++ b/cherrypy/test/test_http.py
@@ -115,11 +115,13 @@ class HTTPTests(helper.CPWebCase):
c = HTTPSConnection('%s:%s' % (self.interface(), self.PORT))
else:
c = HTTPConnection('%s:%s' % (self.interface(), self.PORT))
- if hasattr(c, '_set_content_length'): # python 2.6 doesn't have it
- with patch.object(c, '_set_content_length'):
+
+ # `_get_content_length` is needed for Python 3.6+
+ with patch.object(c, '_get_content_length', lambda body, method: None, create=True):
+ # `_set_content_length` is needed for Python 2.7-3.5
+ with patch.object(c, '_set_content_length', create=True):
c.request("POST", "/")
- else:
- c.request("POST", "/")
+
response = c.getresponse()
self.body = response.fp.read()
self.status = str(response.status)