2

我正在关注 Django v1.6 的Django 教程,并使用 PyDev 在 eclipse 中运行它。我到了测试页面,我想我会把它混合起来(阅读:在我能走路之前跑)并学习生菜。

根据我在网上阅读的内容,默认情况下生菜应该与 PyDev 捆绑在一起。这是有道理的,因为该行在from lettuce import *我的 steps.py 中没有错误,但其余代码确实:

from lettuce import *

@step('Given my poll is (\d+) days in the future')
def have_future_poll(step, number):
    world.number = int(number)

的错误@step是:

未定义变量:step step 发现于:polls.tests.features.steps

对于世界是:

未定义变量:世界

所以我认为它没有正确导入。

我应该如何在 Eclipse 中使用生菜?

4

1 回答 1

2

使用lattuce.worldtry to import worldexplicit:from lattuce import world应该可以工作 - 我在其他应用程序(如逻辑删除)中也遇到过这种现象。但我不知道为什么它不像你那样工作......

要使用@step,您还应该导入该函数/文件/应用程序step(..)from polls.tests.features import steps. 否则,step(..)您的 .py 文件中没有定义命名的方法,并@step成为不存在方法的装饰器。

于 2014-11-21T23:31:18.093 回答