Skip to content

Commit b5aae8a

Browse files
committed
Fix test_new_file_via_rest
This test was failing under python2. The cgi.py module was calling readline(1<<16). I was using the wasgiref/validate.py validator to make sure the wsgi protocol was correct. The validator replaces the normal readline with it's own wrapper. The wrapper doesn't support the max bytes to read value. The same module/wrapper in python 3 fixed this bug. So fixed this by disabling the validator under python2. Keeping it on python3 so we get its benefit.
1 parent 8f7721d commit b5aae8a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

test/test_liveserver.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
skip_zstd = mark_class(pytest.mark.skip(
3333
reason='Skipping zstd tests: zstd library not available'))
3434

35+
import sys
36+
37+
_py3 = sys.version_info[0] > 2
38+
3539
@skip_requests
3640
class SimpleTest(LiveServerTestCase):
3741
# have chicken and egg issue here. Need to encode the base_url
@@ -86,7 +90,13 @@ def teardown_class(cls):
8690

8791
def create_app(self):
8892
'''The wsgi app to start'''
89-
return validator(RequestDispatcher(self.dirname))
93+
if _py3:
94+
return validator(RequestDispatcher(self.dirname))
95+
else:
96+
# wsgiref/validator.py InputWrapper::readline is broke and
97+
# doesn't support the max bytes to read argument.
98+
return RequestDispatcher(self.dirname)
99+
90100

91101
def test_start_page(self):
92102
""" simple test that verifies that the server can serve a start page.
@@ -919,7 +929,6 @@ def test_new_issue_with_file_upload(self):
919929
self.assertEqual(f.text, file_content)
920930
print(f.text)
921931

922-
@pytest.mark.xfail(reason="Work in progress")
923932
def test_new_file_via_rest(self):
924933

925934
session = requests.Session()

0 commit comments

Comments
 (0)