Edgewall Software
Modify

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#9695 closed defect (fixed)

functional-test does not work with Debian/Ubuntu

Reported by: Jun Omae Owned by: Jun Omae
Priority: normal Milestone: 0.12.2
Component: general Version: 0.12-stable
Severity: normal Keywords: testing
Cc: Branch:
Release Notes:

Fixed functional tests on Debian and Ubuntu.

API Changes:
Internal Changes:

Description

functional-test get the below error with Debian.

mechanize._mechanize.BrowserStateError: cannot go to 'http://127.0.0.1:8395'

twill and lxml is installed from debian packges (not using easy_install).

The python-twill debian package does not contain mechanize. Then, I installed python-mechanize package.

jun66j5@localhost:199$ dpkg -l python-lxml python-twill python-mechanize
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name                        Version                     Description
+++-===========================-===========================-======================================================================
ii  python-lxml                 2.1.1-2.1                   pythonic binding for the libxml2 and libxslt libraries
ii  python-mechanize            0.1.11-1.1                  stateful programmatic web browsing
ii  python-twill                0.9-1                       A simple scripting language for Web browsing

Therefore, from _mechanize_dist._mechanize import BrowserStateError always fails. For Debian and Ubuntu, use from mechanize import BrowserStateError instead of.

  • trac/tests/functional/better_twill.py

    diff --git a/trac/tests/functional/better_twill.py b/trac/tests/functional/better_twill.py
    index 8889d6a..aa3d7c3 100755
    a b except ImportError:  
    3131try:
    3232    from _mechanize_dist._mechanize import BrowserStateError as ConnectError
    3333except ImportError:
    34     from urllib2 import URLError as ConnectError
     34    try:
     35        # For python-mechanize on Debian, Ubuntu
     36        from mechanize import BrowserStateError as ConnectError
     37    except ImportError:
     38        from urllib2 import URLError as ConnectError
    3539
    3640
    3741if twill:

Full error log.

jun66j5@localhost:165$ PYTHONPATH=$PWD make functional-test
Python version: Python 2.5.2
figleaf:
coverage:
PYTHONPATH=.:/home/jun66j5/src/trac.git
TRAC_TEST_DB_URI=
server-options= -p 8000  -r -e
python setup.py egg_info
running egg_info
writing requirements to Trac.egg-info/requires.txt
writing Trac.egg-info/PKG-INFO
writing top-level names to Trac.egg-info/top_level.txt
writing dependency_links to Trac.egg-info/dependency_links.txt
writing entry points to Trac.egg-info/entry_points.txt
reading manifest file 'Trac.egg-info/SOURCES.txt'
writing manifest file 'Trac.egg-info/SOURCES.txt'
python trac/tests/functional/__init__.py -v
Traceback (most recent call last):
  File "trac/tests/functional/__init__.py", line 168, in <module>
    unittest.main(defaultTest='suite')
  File "/usr/lib/python2.5/unittest.py", line 768, in __init__
    self.runTests()
  File "/usr/lib/python2.5/unittest.py", line 805, in runTests
    result = self.testRunner.run(self.test)
  File "/usr/lib/python2.5/unittest.py", line 705, in run
    test(result)
  File "/usr/lib/python2.5/unittest.py", line 437, in __call__
    return self.run(*args, **kwds)
  File "/usr/lib/python2.5/unittest.py", line 433, in run
    test(result)
  File "/usr/lib/python2.5/unittest.py", line 437, in __call__
    return self.run(*args, **kwds)
  File "/home/jun66j5/src/trac.git/trac/test.py", line 136, in run
    self.setUp()
  File "/home/jun66j5/src/trac.git/trac/tests/functional/__init__.py", line 122, in setUp
    self._testenv.start()
  File "/home/jun66j5/src/trac.git/trac/tests/functional/testenv.py", line 186, in start
    tc.go(self.url)
  File "/var/lib/python-support/python2.5/twill/commands.py", line 112, in go
    browser.go(url)
  File "/var/lib/python-support/python2.5/twill/browser.py", line 123, in go
    raise BrowserStateError("cannot go to '%s'" % (url,))
mechanize._mechanize.BrowserStateError: cannot go to 'http://127.0.0.1:8395'
make: *** [functional-test] Error 1

Attachments (0)

Change History (4)

comment:1 by Remy Blank, 14 years ago

Twill bundles its own copy of mechanize, and does some sys.path magic to make it appear as a top-level package _mechanize_dist. Debian has a history of disliking bundled copies (often for good reasons), so they probably strip the bundled copy.

Maybe we could import BrowserStateError from twill.browser instead, as that's where twill imports and uses it?

in reply to:  1 comment:2 by Jun Omae, 14 years ago

Replying to rblank:

Maybe we could import BrowserStateError from twill.browser instead, as that's where twill imports and uses it?

I tried from twill.browser import BrowserStateError. It is working.

I verified with…

  • CentOS: python 2.4 with twill (using easy_install)
  • Debian: python 2.5 with python-twill and python-mechanize package
  • Ubuntu: python 2.5, python 2.6 with python-twill and python-mechanize package
  • trac/tests/functional/better_twill.py

    diff --git a/trac/tests/functional/better_twill.py b/trac/tests/functional/better_twill.py
    index 8889d6a..9a20d93 100755
    a b except ImportError:  
    2727
    2828# When twill tries to connect to a site before the site is up, it raises an
    2929# exception.  In 0.9b1, it's urlib2.URLError, but in -latest, it's
    30 # _mechanize_dist._mechanize.BrowserStateError.
     30# twill.browser.BrowserStateError.
    3131try:
    32     from _mechanize_dist._mechanize import BrowserStateError as ConnectError
     32    from twill.browser import BrowserStateError as ConnectError
    3333except ImportError:
    3434    from urllib2 import URLError as ConnectError
    3535

comment:3 by Christian Boos, 14 years ago

Resolution: fixed
Status: newclosed

Verified on Windows, with Python 2.4 to 2.7.

Patch applied in r10243.

comment:4 by Christian Boos, 14 years ago

Owner: set to Jun Omae

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.