diff options
author | Diogo Baeder <diogobaeder@yahoo.com.br> | 2015-12-17 18:51:29 -0200 |
---|---|---|
committer | Diogo Baeder <diogobaeder@yahoo.com.br> | 2015-12-17 18:51:29 -0200 |
commit | faed0f5803a1c894c33e6bb9850d42ba91872ab6 (patch) | |
tree | cc97dcd33ead681fc5af060b179d48fc75211720 /cherrypy/test/test_http.py | |
parent | ab97a291d06048aff1bb25a806ef75555412e639 (diff) | |
download | cherrypy-git-faed0f5803a1c894c33e6bb9850d42ba91872ab6.tar.gz |
Fixing no-content-length test
Diffstat (limited to 'cherrypy/test/test_http.py')
-rw-r--r-- | cherrypy/test/test_http.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/cherrypy/test/test_http.py b/cherrypy/test/test_http.py index ff96afa2..ed0aabda 100644 --- a/cherrypy/test/test_http.py +++ b/cherrypy/test/test_http.py @@ -5,6 +5,8 @@ import mimetypes import socket import sys +from mock import patch + import cherrypy from cherrypy._cpcompat import HTTPConnection, HTTPSConnection, ntob, py3k @@ -35,12 +37,12 @@ from cherrypy.test import helper class HTTPTests(helper.CPWebCase): - + def make_connection(self): if self.scheme == "https": return HTTPSConnection('%s:%s' % (self.interface(), self.PORT)) else: - return HTTPConnection('%s:%s' % (self.interface(), self.PORT)) + return HTTPConnection('%s:%s' % (self.interface(), self.PORT)) def setup_server(): class Root: @@ -78,7 +80,7 @@ class HTTPTests(helper.CPWebCase): summary.append("%s * %d" % (curchar, count)) return ", ".join(summary) post_multipart.exposed = True - + @cherrypy.expose def post_filename(self, myfile): '''Return the name of the file which was uploaded.''' @@ -111,7 +113,8 @@ class HTTPTests(helper.CPWebCase): c = HTTPSConnection('%s:%s' % (self.interface(), self.PORT)) else: c = HTTPConnection('%s:%s' % (self.interface(), self.PORT)) - c.request("POST", "/") + with patch.object(c, '_set_content_length'): + c.request("POST", "/") response = c.getresponse() self.body = response.fp.read() self.status = str(response.status) @@ -140,7 +143,7 @@ class HTTPTests(helper.CPWebCase): self.status = str(response.status) self.assertStatus(200) self.assertBody(", ".join(["%s * 65536" % c for c in alphabet])) - + def test_post_filename_with_commas(self): '''Testing that we can handle filenames with commas. This was reported as a bug in: |