On Jan 29, 1:07 am, "Max Ischenko" <[EMAIL PROTECTED]> wrote:
> I run into an interesting issue with paste.fixture and url_for.
>
> I have a simple test case:
>
> class TestQuotesController(TestController):
> def test_create(self):
> eq_('/quotes/new;create', url_for(controller='quotes',
> action='create'))
>
> If I run nosetests on the file where it is defined all is fine and
> test passes. If I run a whole test suite I got an error in the test
> case:
>
> FAIL: test_create
> (doupy.tests.functional.test_quotes.TestQuotesController)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File "/home/max/projects/dou-trunk/site/doupy/doupy/tests/functional/
> test_quotes.py", line 7, in test_create
> eq_('/quotes/new;create', url_for(controller='quotes',
> action='create'))
> File "/usr/lib/python2.4/site-packages/nose-0.9.1-py2.4.egg/nose/
> tools.py", line 23, in eq_
> assert a == b, msg or "%r != %r" % (a, b)
> AssertionError: '/quotes/new;create' != '/quotes/new;create?
> name=contacts'
>
> It looks like the "previous state" hasn't been cleared and the 'name'
> qs arg got passed to the next test case.
>
> My TestController looks like this:
>
> class TestController(TestCase):
> def __init__(self, *args):
> wsgiapp = loadapp('config:development.ini',
> relative_to=conf_dir)
> self.app = paste.fixture.TestApp(wsgiapp)
> TestCase.__init__(self, *args)
>
> What should I do to fix the problem?
Ah yes, I generally assumed that you wouldn't be testing url_for
directly as its unit tests already exercise it. To clear out the route
memory manually (maybe in one of the test methods special functions
thats called every test), do:
from routes import request_config
config = request_config()
config.mapper_dict = {}
That will clear out the route memory. I had assumed people would test
their apps with Paste's app.get which creates a new request (thus sets
up the route memory).
HTH,
Ben
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---