Python 属性错误:';螺纹。_本地';对象没有属性';浏览器&x27;

Python 属性错误:';螺纹。_本地';对象没有属性';浏览器&x27;,python,django,lettuce,splinter,Python,Django,Lettuce,Splinter,我被python中使用莴苣的AttributeError卡住了 我试图在网站上遵循莴苣=0.2.19文档,但无法找出我做错了什么 我正在使用virtualenv创建一个干净的环境。 我想为测试添加一个非常愚蠢的特性 目录的组织是 features |_terrain.py |_ user_reauth.feature |_ user_steps.py 这是我的terrain.py文件: from lettuce import before, after, world f

我被python中使用莴苣的AttributeError卡住了

我试图在网站上遵循莴苣=0.2.19文档,但无法找出我做错了什么

我正在使用virtualenv创建一个干净的环境。 我想为测试添加一个非常愚蠢的特性

目录的组织是

features
    |_terrain.py
    |_ user_reauth.feature
    |_ user_steps.py
这是我的terrain.py文件:

from lettuce import before, after, world
from lettuce.django import django_url
from selenium import selenium

@before.harvest
def prepare_browser_driver(variables):
    if variables.get('run_server', False) is True:
        world.browser = selenium('localhost', 4444, '*firefox', django_url('/'))
        world.browser.start()

@after.harvest
def shutdown_browser_driver(results):
    world.browser.stop()
以及用户_steps.py文件:

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

@step(u'User is already authenticated with username "(.*)')
def user_is(step, username):
    assert 1==1

@step(u'I go to the "(.*)" URL')
def i_go_to_the_url(step, url):
    world.response = world.browser.visit(django_url(url))

@step(u'I should see "(.*)"')
def i_should_see(step, text):
    assert text in world.browser.html
使用以下命令时:

python manage.py harvest --settings=my_settings dir/features/user_reauth.feature
我得到以下错误:

line 13, in shutdown_browser_driver
    world.browser.stop()
AttributeError: 'thread._local' object has no attribute 'browser'

据我所知,在通过
manage.py harvest
启动测试时,莴苣希望在manage.py所在的文件夹中找到terrain.py。
尝试将terrain.py放在该文件夹中。

据我所知,在通过
manage.py harvest
启动测试时,莴苣希望在manage.py所在的文件夹中找到terrain.py。 尝试将terrain.py放在该文件夹中