[pypy-issue] [issue1172] call to print samples in pypy's doctests errors in mechanize's test_browser.doctest

Ian Delaney tracker at bugs.pypy.org
Tue Jun 12 17:50:42 CEST 2012


New submission from Ian Delaney <della5 at iinet.com.au>:

running pypy in mechanize(-0.2.5) tests.
A failure results in the doctest portion of the suite.

It bailed out on 3 instances of the 1 expected response.

from  test/test_browser.doctest

>>> br = TestHttpBrowser()
>>> r = br.open("http://example.com")
>>> print response_impl(r)
StringI
>>> r2 = br.open("http://example.com")
>>> print response_impl(r2)
StringI
>>> print response_impl(r)
eofresponse

So should .set_response()

>>> br.set_response(test_response())
>>> print response_impl(r2)
eofresponse


.visit_response() works very similarly to .open()

>>> br = TestHttpBrowser()
>>> r = br.open("http://example.com")
>>> r2 = test_response(url="http://example.com/2")
>>> print response_impl(r2)
StringI

when tun yields

FAIL: Doctest: test_browser.doctest
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test-tools/doctest.py", line 2178, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for test_browser.doctest
  File
"/mnt/gen2/TmpDir/portage/dev-python/mechanize-0.2.5/work/mechanize-0.2.5/test/test_browser.doctest",
line 0

----------------------------------------------------------------------
File
"/mnt/gen2/TmpDir/portage/dev-python/mechanize-0.2.5/work/mechanize-0.2.5/test/test_browser.doctest",
line 20, in test_browser.doctest
Failed example:
    print response_impl(r)
Expected:
    StringI
Got:
    cStringIO.StringI
----------------------------------------------------------------------
File
"/mnt/gen2/TmpDir/portage/dev-python/mechanize-0.2.5/work/mechanize-0.2.5/test/test_browser.doctest",
line 23, in test_browser.doctest
Failed example:
    print response_impl(r2)
Expected:
    StringI
Got:
    cStringIO.StringI
----------------------------------------------------------------------
File
"/mnt/gen2/TmpDir/portage/dev-python/mechanize-0.2.5/work/mechanize-0.2.5/test/test_browser.doctest",
line 40, in test_browser.doctest
Failed example:
    print response_impl(r2)
Expected:
    StringI
Got:
    cStringIO.StringI

and sure enough; go into an interpreter and repeat the tested samples

testuser at archtester ~ # pypy-c1.8(or 9)

>>>> import mechanize
>>>> from mechanize._response import test_response
>>>> from test.test_browser import TestBrowser2, make_mock_handler
>>>>
>>>> class TestHttpHandler(mechanize.BaseHandler):
....     def http_open(self, request):
....         return test_response(url=request.get_full_url())
>>>> class TestHttpHandler(mechanize.BaseHandler):
....     def http_open(self, request):
....         return test_response(url=request.get_full_url())
>>>> class TestHttpHandler(mechanize.BaseHandler):
....     def http_open(self, request):
....         return test_response(url=request.get_full_url())
....
>>>> class TestHttpBrowser(TestBrowser2):
....     handler_classes = TestBrowser2.handler_classes.copy()
....     handler_classes["http"] = TestHttpHandler
....     default_schemes = ["http"]
....
>>>> def response_impl(response):
....     return response.wrapped.fp.__class__.__name__
....
>>>> br = TestHttpBrowser()
>>>> r = br.open("http://example.com")
>>>> print response_impl(r)
cStringIO.StringI
>>>> r2 = br.open("http://example.com")
>>>> print response_impl(r2)
cStringIO.StringI
>>>> print response_impl(r)
eofresponse
>>>> br = TestHttpBrowser()
>>>> r = br.open("http://example.com")
>>>> r2 = test_response(url="http://example.com/2")
>>>> print response_impl(r2)
cStringIO.StringI

----------
assignedto: arigo
files: test_browser.doctest
messages: 4427
nosy: arigo, idella5, pypy-issue
priority: performance bug
release: 1.9
status: chatting
title: call to print samples in pypy's doctests errors in mechanize's test_browser.doctest

________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue1172>
________________________________________


More information about the pypy-issue mailing list