doctest failures

Issue #24 resolved
Arfrever Frehtes Taifersar Arahesis
created an issue

Some doctests fail. A part of these problems occurs only with Python 3.

"NameError: global name 'Response' is not defined" is a bug in pyquery. Other problems need to be fixed in WebTest iself.

The attached patch seems to fix these problems in WebTest.

{{{
$ nosetests-3.2
Doctest: index.txt ... FAIL
test_click (tests.test_click.TestClick) ... ok
test_click_u (tests.test_click.TestClick) ... ok
test_click_utf8 (tests.test_click.TestClick) ... ok
test_parse_attrs (tests.test_click.TestClick) ... ok
test_cookies (tests.test_cookie.TestCookies) ... ok
test_cookies2 (tests.test_cookie.TestCookies) ... ok
test_preserve_cookies (tests.test_cookie.TestCookies) ... ok
test_get_extra_environ (tests.test_extra_environ.TestEnviron) ... ok
test_post_extra_environ (tests.test_extra_environ.TestEnviron) ... ok
test_request_extra_environ (tests.test_extra_environ.TestEnviron) ... ok
test_file_upload_binary (tests.test_file_upload.TestFileUpload) ... ok
test_file_upload_with_filename_and_contents (tests.test_file_upload.TestFileUpload) ... ok
test_file_upload_with_filename_only (tests.test_file_upload.TestFileUpload) ... ok
test_multiple_file_uploads_with_filename_and_contents (tests.test_file_upload.TestFileUpload) ... ok
test_no_uploads_error (tests.test_file_upload.TestFileUpload) ... ok
test_upload_without_file (tests.test_file_upload.TestFileUpload) ... ok
test_url_with_fragments (tests.test_fragments.TestFragemts) ... ok
test_url_without_fragments (tests.test_fragments.TestFragemts) ... ok
test_form_lint (tests.test_input.TestFormLint) ... ok
test_input (tests.test_input.TestInput) ... ok
test_input_no_default (tests.test_input.TestInput) ... ok
test_input_unicode (tests.test_input.TestInput) ... ok
test_app_script_name (tests.test_script_name.TestScriptName) ... ok
test_script_name (tests.test_script_name.TestScriptName) ... ok
test_script_name_doesnt_match (tests.test_script_name.TestScriptName) ... ok
test_multiple_select (tests.test_select.TestSelect) ... ok
test_multiple_select_forced_values (tests.test_select.TestSelect) ... ok
test_multiple_select_no_default (tests.test_select.TestSelect) ... ok
test_single_select (tests.test_select.TestSelect) ... ok
test_single_select_forced_value (tests.test_select.TestSelect) ... ok
test_single_select_no_default (tests.test_select.TestSelect) ... ok
test_unicode_select (tests.test_select.TestSelect) ... ok
test_selenium (tests.test_selenium.TestApp) ... ok
test_webtest (tests.test_selenium.TestApp) ... ok
test_204 (tests.test_testing.TestTesting) ... /tmp/WebTest-1.3.2/webtest/lint3.py:462: WSGIWarning: Content-Type header found in a 204 response, which not return content.
WSGIWarning)
ok
test_303 (tests.test_testing.TestTesting) ... ok
test_404 (tests.test_testing.TestTesting) ... ok
test_delete_params (tests.test_testing.TestTesting) ... /tmp/WebTest-1.3.2/webtest/app.py:843: WSGIWarning: You are not supposed to send a body in a DELETE request. Most web servers will ignore it
lint.WSGIWarning)
ok
test_exception (tests.test_testing.TestTesting) ... ok
test_fake_dict (tests.test_testing.TestTesting) ... ok
test_get_params (tests.test_testing.TestTesting) ... ok
test_options (tests.test_testing.TestTesting) ... ok
test_testing (tests.test_testing.TestTesting) ... ok
test_url_class (tests.test_testing.TestTesting) ... ok
tests.test_testing.test_print_unicode ... °C
ok

======================================================================
FAIL: Doctest: index.txt


Traceback (most recent call last):
File "/usr/lib64/python3.2/doctest.py", line 2118, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for index.txt
File "/tmp/WebTest-1.3.2/docs/index.txt", line 0


File "/tmp/WebTest-1.3.2/docs/index.txt", line 260, in index.txt
Failed example:
fields = list(form.fields.items()); fields.sort(); fields
Expected:
[(u'name', [<Text name="name">]), (u'submit', [<Submit name="submit">])]
Got:
[('name', [<Text name="name">]), ('submit', [<Submit name="submit">])]


File "/tmp/WebTest-1.3.2/docs/index.txt", line 274, in index.txt
Failed example:
print(res)
Expected:
Response: 200 OK
Content-Type: text/plain
...
-- Body ----------
submit=Submit%21&name=Bob
Got:
Response: 200 OK
Content-Type: text/plain
CONTENT_LENGTH: 25
CONTENT_TYPE: application/x-www-form-urlencoded
HTTP_HOST: localhost:80
PATH_INFO: /form-submit
QUERY_STRING:
REQUEST_METHOD: POST
SCRIPT_NAME:
SERVER_NAME: localhost
SERVER_PORT: 80
SERVER_PROTOCOL: HTTP/1.0
paste.testing: True
paste.testing_variables: {}
paste.throw_errors: True
webob._parsed_query_vars: (GET([]), '')
wsgi.errors: <webtest.lint3.ErrorWrapper object at 0x29890d0>
wsgi.input: <webtest.lint3.InputWrapper object at 0x2989090>
wsgi.multiprocess: False
wsgi.multithread: False
wsgi.run_once: False
wsgi.url_scheme: 'http'
wsgi.version: (1, 0)
-- Body ----------
submit=Submit%21&name=Bob


File "/tmp/WebTest-1.3.2/docs/index.txt", line 332, in index.txt
Failed example:
res.html.body.div.string
Expected:
u'hey!'
Got:
'hey!'


File "/tmp/WebTest-1.3.2/docs/index.txt", line 334, in index.txt
Failed example:
res.lxml
Expected:
<Element html at ...>
Got:
<Element html at 0x2974710>


File "/tmp/WebTest-1.3.2/docs/index.txt", line 341, in index.txt
Failed example:
res.json.values()
Expected:
[1, 2]
Got:
dict_values([1, 2])


File "/tmp/WebTest-1.3.2/docs/index.txt", line 346, in index.txt
Failed example:
res.xml
Expected:
<Element ...>
Got:
<Element 'xml' at 0x2b309d0>


File "/tmp/WebTest-1.3.2/docs/index.txt", line 352, in index.txt
Failed example:
res.lxml
Expected:
<Element xml at ...>
Got:
<Element xml at 0x2aedb40>


File "/tmp/WebTest-1.3.2/docs/index.txt", line 358, in index.txt
Failed example:
res.pyquery('message')
Exception raised:
Traceback (most recent call last):
File "/usr/lib64/python3.2/doctest.py", line 1253, in run
compileflags, 1), test.globs)
File "<doctest index.txt[36]>", line 1, in <module>
res.pyquery('message')
File "/tmp/WebTest-1.3.2/webtest/app.py", line 616, in pyquery
d = PyQuery(self.testbody)
File "/usr/lib64/python3.2/site-packages/pyquery/ajax.py", line 20, in
init__
self.response = Response()
NameError: global name 'Response' is not defined


File "/tmp/WebTest-1.3.2/docs/index.txt", line 360, in index.txt
Failed example:
res.pyquery('message').text()
Exception raised:
Traceback (most recent call last):
File "/usr/lib64/python3.2/doctest.py", line 1253, in run
compileflags, 1), test.globs)
File "<doctest index.txt[37]>", line 1, in <module>
res.pyquery('message').text()
File "/tmp/WebTest-1.3.2/webtest/app.py", line 616, in pyquery
d = PyQuery(self.testbody)
File "/usr/lib64/python3.2/site-packages/pyquery/ajax.py", line 20, in
init__
self.response = Response()
NameError: global name 'Response' is not defined

raise self.failureException(self.format_failure(<_io.StringIO object at 0x241d750>.getvalue()))

Name Stmts Miss Cover Missing

webtest 16 0 100%
webtest.app 895 155 83% 42, 66, 69-70, 73, 102, 106, 122, 225-234, 257, 275, 277-278, 281-285, 348-364, 389, 406-409, 439, 443-445, 449-451, 475, 483, 485, 500, 505-506, 523, 528-535, 556, 561-562, 566-567, 585, 593-594, 608, 613-614, 617, 626-640, 674-677, 744, 754, 791, 827, 908, 913, 919, 923, 955-959, 1011-1012, 1016-1021, 1029-1030, 1040, 1047-1052, 1067, 1117, 1127, 1130, 1164, 1188, 1255, 1279, 1284, 1422-1427, 1462-1465, 1490, 1565, 1569-1573, 1580-1582, 1628, 1647, 1665-1667, 1675-1693, 1703-1705
webtest.compat 64 32 50% 37-65, 72-78
webtest.debugapp 37 1 97% 60
webtest.lint 192 147 23% 140-181, 187, 190-193, 196-198, 201-206, 209-213, 216, 222, 225-226, 229, 232-233, 236, 242, 245-246, 252, 256, 262-265, 268, 271-285, 290-292, 295-298, 303-363, 369-370, 376-377, 383-392, 399-419, 425-447, 451, 460, 468
webtest.lint3 209 40 81% 163, 201-203, 206-211, 214-218, 221, 230-231, 234, 237-238, 241, 250-251, 257, 261, 281, 297, 301, 325, 350, 397, 416-417, 433-434, 465-468, 492
webtest.sel 577 392 32% 41-45, 76-90, 100-120, 132, 138, 163-165, 168-170, 176-177, 180-204, 207-214, 232-245, 250, 254, 257-273, 277-311, 315-336, 340-354, 364-374, 379-384, 388, 392, 395-401, 406-408, 413, 441-443, 446-453, 457, 461-466, 470, 474-475, 479, 483, 487, 491, 494, 497-506, 519-529, 532-534, 537, 541, 544, 552, 555, 564-565, 569, 573, 577, 582, 587, 591-593, 596, 609-614, 625, 628, 631, 642-645, 648-651, 654-655, 666-669, 672-691, 717-726, 729-737, 764, 769, 781, 784, 793-803, 806-811, 819-828, 840-844, 847-867, 870, 877, 887-888, 895, 898, 909-912, 916-920, 924-937, 941-946, 953, 966-979


TOTAL 1990 767 61%

Ran 46 tests in 1.973s

FAILED (failures=1)
}}}

Comments (5)

  1. Log in to comment