Edgewall Software
Modify

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#13233 closed defect (fixed)

Functional test is failed in AppVeyor on Python 2.7.17

Reported by: Jun Omae Owned by: Jun Omae
Priority: normal Milestone: 1.0.20
Component: general Version: 1.2.5
Severity: normal Keywords: travis-ci
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Work around for InvalidURL from functional-test since Python 2.7.17.

Description

======================================================================
ERROR: runTest (trac.tests.functional.testcases.RegressionTestTicket3663)
Regression test for non-UTF-8 PATH_INFO (#3663)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\projects\trac\trac\tests\functional\testcases.py", line 301, in runTest
    self._tester.go_to_wiki(u'été'.encode('latin1'))
  File "C:\projects\trac\trac\tests\functional\tester.py", line 148, in go_to_wiki
    self.go_to_url(wiki_url)
  File "C:\projects\trac\trac\tests\functional\tester.py", line 117, in go_to_url
    tc.go(url)
  File "C:\Python27\lib\site-packages\twill\commands.py", line 112, in go
    browser.go(url)
  File "C:\Python27\lib\site-packages\twill\browser.py", line 113, in go
    self._journey('open', u)
  File "C:\Python27\lib\site-packages\twill\browser.py", line 523, in _journey
    r = func(*args, **kwargs)
  File "C:\Python27\lib\site-packages\twill\other_packages\_mechanize_dist\_mechanize.py", line 212, in open
    return self._mech_open(url, data)
  File "C:\Python27\lib\site-packages\twill\other_packages\_mechanize_dist\_mechanize.py", line 238, in _mech_open
    response = UserAgentBase.open(self, request, data)
  File "C:\Python27\lib\site-packages\twill\other_packages\_mechanize_dist\_opener.py", line 181, in open
    response = urlopen(self, req, data)
  File "C:\Python27\lib\urllib2.py", line 447, in _open
    '_open', req)
  File "C:\Python27\lib\urllib2.py", line 407, in _call_chain
    result = func(*args)
  File "C:\Python27\lib\site-packages\twill\_browser.py", line 16, in http_open
    return self.do_open(wsgi_intercept.WSGI_HTTPConnection, req)
  File "C:\Python27\lib\site-packages\twill\other_packages\_mechanize_dist\_http.py", line 674, in do_open
    h.request(req.get_method(), req.get_selector(), req.data, headers)
  File "C:\Python27\lib\httplib.py", line 1069, in request
    self._send_request(method, url, body, headers)
  File "C:\Python27\lib\httplib.py", line 1103, in _send_request
    self.putrequest(method, url, **skips)
  File "C:\Python27\lib\httplib.py", line 940, in putrequest
    self._validate_path(url)
  File "C:\Python27\lib\httplib.py", line 1030, in _validate_path
    raise InvalidURL(msg)
InvalidURL: URL can't contain control characters. '/wiki/\xe9t\xe9' (found at least '\xe9')

See also:

Attachments (0)

Change History (4)

comment:1 by Ryan J Ollos, 4 years ago

Keywords: travis-ci added

Similar failures on Travis CI

======================================================================
ERROR: runTest (trac.tests.functional.testcases.RegressionTestTicket3663)
Regression test for non-UTF-8 PATH_INFO (#3663)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/travis/build/edgewall/trac/trac/tests/functional/testcases.py", line 257, in runTest
    self._tester.go_to_wiki(u'été'.encode('latin1'))
  File "/Users/travis/build/edgewall/trac/trac/tests/functional/tester.py", line 141, in go_to_wiki
    self.go_to_url(wiki_url)
  File "/Users/travis/build/edgewall/trac/trac/tests/functional/tester.py", line 110, in go_to_url
    tc.go(url)
  File "/Users/travis/venv-2.7.17/lib/python2.7/site-packages/twill/commands.py", line 112, in go
    browser.go(url)
  File "/Users/travis/venv-2.7.17/lib/python2.7/site-packages/twill/browser.py", line 113, in go
    self._journey('open', u)
  File "/Users/travis/venv-2.7.17/lib/python2.7/site-packages/twill/browser.py", line 523, in _journey
    r = func(*args, **kwargs)
  File "/Users/travis/venv-2.7.17/lib/python2.7/site-packages/twill/other_packages/_mechanize_dist/_mechanize.py", line 212, in open
    return self._mech_open(url, data)
  File "/Users/travis/venv-2.7.17/lib/python2.7/site-packages/twill/other_packages/_mechanize_dist/_mechanize.py", line 238, in _mech_open
    response = UserAgentBase.open(self, request, data)
  File "/Users/travis/venv-2.7.17/lib/python2.7/site-packages/twill/other_packages/_mechanize_dist/_opener.py", line 181, in open
    response = urlopen(self, req, data)
  File "/Users/travis/.pyenv/versions/2.7.17/lib/python2.7/urllib2.py", line 447, in _open
    '_open', req)
  File "/Users/travis/.pyenv/versions/2.7.17/lib/python2.7/urllib2.py", line 407, in _call_chain
    result = func(*args)
  File "/Users/travis/venv-2.7.17/lib/python2.7/site-packages/twill/_browser.py", line 16, in http_open
    return self.do_open(wsgi_intercept.WSGI_HTTPConnection, req)
  File "/Users/travis/venv-2.7.17/lib/python2.7/site-packages/twill/other_packages/_mechanize_dist/_http.py", line 674, in do_open
    h.request(req.get_method(), req.get_selector(), req.data, headers)
  File "/Users/travis/.pyenv/versions/2.7.17/lib/python2.7/httplib.py", line 1069, in request
    self._send_request(method, url, body, headers)
  File "/Users/travis/.pyenv/versions/2.7.17/lib/python2.7/httplib.py", line 1103, in _send_request
    self.putrequest(method, url, **skips)
  File "/Users/travis/.pyenv/versions/2.7.17/lib/python2.7/httplib.py", line 940, in putrequest
    self._validate_path(url)
  File "/Users/travis/.pyenv/versions/2.7.17/lib/python2.7/httplib.py", line 1030, in _validate_path
    raise InvalidURL(msg)
InvalidURL: URL can't contain control characters. '/wiki/\xe9t\xe9' (found at least '\xe9')
----------------------------------------------------------------------
Ran 178 tests in 326.222s
FAILED (errors=1)
SKIP: versioncontrol/tests/functional.py (no svn bindings)
make: *** [functional-test] Error 1
The command "if [ "$TRAVIS_BUILD_STAGE_NAME" = Test ]; then make Trac.egg-info compile unit-test functional-test; fi" exited with 2.
cache.2
store build cache
Done. Your build exited with 1.

comment:2 by Jun Omae, 4 years ago

Owner: set to Jun Omae
Status: newassigned

The exception is raised from HTTPConnection._validate_path in httplib module. It is able to avoid to override _validate_path of HTTPConnection subclass but we cannot override the method because httplib is used from mechanize module bundled in twill module.

Instead, we could avoid the exception by monkey-patch of httplib._contains_disallowed_url_pchar_re.

Results:

  • trac/tests/functional/testcases.py

    diff --git a/trac/tests/functional/testcases.py b/trac/tests/functional/testcases.py
    index 1ada3aeeb..ccae51f12 100755
    a b def runTest(self):  
    237237
    238238        Verify that URLs not encoded with UTF-8 are reported as invalid.
    239239        """
    240         # invalid PATH_INFO
    241         self._tester.go_to_wiki(u'été'.encode('latin1'))
    242         tc.code(404)
    243         tc.find('Invalid URL encoding')
    244         # invalid SCRIPT_NAME
    245         tc.go(u'été'.encode('latin1'))
    246         tc.code(404)
    247         tc.find('Invalid URL encoding')
     240        import httplib
     241        try:
     242            # Work around for InvalidURL since Python 2.7.17 (#13233)
     243            saved_re = \
     244                httplib._contains_disallowed_url_pchar_re \
     245                if hasattr(httplib, '_contains_disallowed_url_pchar_re') \
     246                else None
     247            if saved_re:
     248                httplib._contains_disallowed_url_pchar_re = \
     249                    re.compile(r'[\x00-\x20]')
     250            # invalid PATH_INFO
     251            self._tester.go_to_wiki(u'été'.encode('latin1'))
     252            tc.code(404)
     253            tc.find('Invalid URL encoding')
     254            # invalid SCRIPT_NAME
     255            tc.go(u'été'.encode('latin1'))
     256            tc.code(404)
     257            tc.find('Invalid URL encoding')
     258        finally:
     259            if saved_re:
     260                httplib._contains_disallowed_url_pchar_re = saved_re
    248261
    249262
    250263class RegressionTestTicket6318(FunctionalTwillTestCaseSetup):

comment:3 by Jun Omae, 4 years ago

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Committed in [17223] and merged in [17224-17226].

comment:4 by Ryan J Ollos, 4 years ago

Internal Changes: modified (diff)
Release Notes: modified (diff)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jun Omae to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.