gabrielfalcao / lettuce

Behavior-driven-development tool for python, inspired by Cucumber for Ruby ⛺
http://lettuce.it
GNU General Public License v3.0
1.27k stars 323 forks source link

django_url None on global import #467

Open Gandi24 opened 10 years ago

Gandi24 commented 10 years ago

There is some issue with loading django_url variable from letttuce.django. When the function is implemented like in documentation:

from lettuce import step, world
from lettuce.django import django_url

@step(r'I log in$')
def log_in_trader(step):
    world.browser.visit(django_url(reverse('login')))

it keeps returning:

    Traceback (most recent call last):
      File "/env/local/lib/python2.7/site-packages/lettuce/core.py", line 144, in __call__
        ret = self.function(self.step, *args, **kw)
      File "/vagrant/app/starspread/utils/features/login.py", line 8, in log_in_trader
        world.browser.visit(django_url(reverse('login')))
    TypeError: 'NoneType' object is not callable

what is caused by None django_url.

The fix I've done is implementing all functions this way:

from lettuce import step, world

@step(r'I log in$')
def log_in_trader(step):
    from lettuce.django import django_url
    world.browser.visit(django_url(reverse('login')))

what fixes the NoneType Error.

I'm running 0.2.20 version of lettuce with 1.9.7 version of phantomjs.

nattster commented 9 years ago

Seem like we cannot use

from lettuce.django import django_url

But this one works:

from lettuce import django
django.django_url('/')