views:

98

answers:

0

I've been working with an open source project that it not working correctly in Production but does work in Development. I believe I will need to refactor part of the project.

The project has no tests, so I'm trying to learn how to use Twill to verify that my refactoring doesn't break the project during Development.

I also want to be able to run these tests against the Production setup because that's were the bug appears now.

Twill looked like it might be an easy way to accomplish this.

It appears that Twill doesn't like Relative Path links, so I decided to look at Django-test-utils because, allegedly it does support relative links.

The Twill test runner in Django-test-utils doesn't seem to be working as expected:

$ python manage.py test forum --settings=settings

    ...skip stuff...
======================================================================
ERROR: test_root_page (CNPROG.forum.tests.tests_twill.test_twill_browser)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/Bryan/work/CNPROG/../CNPROG/forum/tests/tests_twill.py", line 12, in test_root_page
    twill.go('/')
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django_test_utils-0.3-py2.6.egg/test_utils/utils/twill_runner.py", line 297, in go
    browser.go(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django_test_utils-0.3-py2.6.egg/test_utils/utils/twill_runner.py", line 199, in go
    return super(_EasyTwillBrowser, self).go(url)
  File "/usr/local/lib/python2.6/site-packages/twill-0.9-py2.6.egg/twill/browser.py", line 113, in go
    self._journey('open', u)
  File "/usr/local/lib/python2.6/site-packages/twill-0.9-py2.6.egg/twill/browser.py", line 523, in _journey
    r = func(*args, **kwargs)
  File "/usr/local/lib/python2.6/site-packages/twill-0.9-py2.6.egg/twill/other_packages/_mechanize_dist/_mechanize.py", line 212, in open
    return self._mech_open(url, data)
  File "/usr/local/lib/python2.6/site-packages/twill-0.9-py2.6.egg/twill/other_packages/_mechanize_dist/_mechanize.py", line 224, in _mech_open
    "can't fetch relative reference: "
BrowserStateError: can't fetch relative reference: not viewing any document


from unittest import TestCase
from test_utils.utils import twill_runner as twill

class test_twill_browser(TestCase):
    twill.setup()
    try:
        def test_root_page(self):
            twill.go('/')
            self.assertTrue(twill.get_code() in 200, 201)

    finally:
        twill.teardown()