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 | 80edcf151f2faf6bc6432545865ad55bdfcf44f4 (patch) | |
tree | 5d00bc57679d47421dbe1555a19a9da33622f813 | |
parent | bcd26b89910534b28e39ff7faecb718df24ca41d (diff) | |
download | cherrypy-80edcf151f2faf6bc6432545865ad55bdfcf44f4.tar.gz |
Fixing no-content-length test
-rw-r--r-- | cherrypy/test/test_http.py | 13 | ||||
-rw-r--r-- | tox.ini | 1 |
2 files changed, 9 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: @@ -3,6 +3,7 @@ envlist = py26, py27, py32, py33, pypy [testenv] deps = nose + mock Routes commands = nosetests -s [] |