Mercurial > p > roundup > code
diff test/test_liveserver.py @ 6569:3ae0c0fb2d08
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.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Tue, 21 Dec 2021 02:28:25 -0500 |
| parents | 59eebe55ca1d |
| children | 198875530c04 |
line wrap: on
line diff
--- a/test/test_liveserver.py Tue Dec 21 02:07:29 2021 -0500 +++ b/test/test_liveserver.py Tue Dec 21 02:28:25 2021 -0500 @@ -32,6 +32,10 @@ skip_zstd = mark_class(pytest.mark.skip( reason='Skipping zstd tests: zstd library not available')) +import sys + +_py3 = sys.version_info[0] > 2 + @skip_requests class SimpleTest(LiveServerTestCase): # have chicken and egg issue here. Need to encode the base_url @@ -86,7 +90,13 @@ def create_app(self): '''The wsgi app to start''' - return validator(RequestDispatcher(self.dirname)) + if _py3: + return validator(RequestDispatcher(self.dirname)) + else: + # wsgiref/validator.py InputWrapper::readline is broke and + # doesn't support the max bytes to read argument. + return RequestDispatcher(self.dirname) + def test_start_page(self): """ simple test that verifies that the server can serve a start page. @@ -919,7 +929,6 @@ self.assertEqual(f.text, file_content) print(f.text) - @pytest.mark.xfail(reason="Work in progress") def test_new_file_via_rest(self): session = requests.Session()
