清新用法测试结果不正确

时间:2014-01-15 15:55:00

标签: python testing bdd nose nosetests

我刚安装了Freshen,我正试图抓住它。

运行以下测试,但它提供的输出不正确。

测试:get_user.feature

Feature: Retrieve an existing User
    When a Users ID (ID, Email, User-name) is entered,
    An object containing all the Users information is returned

    Scenario: Get existing User from their ID
        Given I have the user where their id is '288' and account id is '57'
        Then their username should equal adminuserxxx

steps.py

from freshen import *
from freshen.checks import *

import user_operations
import util
#The URL of the API
api_root = "http://api.stuff.com/v1/core";

#The ID of the Application
appid = "1234567";

#Our private key
secret = "987654321";

#Headers
headers = {'Accept':'application/json', 'Content-Type':'application/json'}

@Before
def before(sc):
    scc.headers = headers
    util.get_auth_token_and_scope(api_root, appid, secret, scc.headers) #An authorization token is added to scc.headers here

@Given("I have the user where their id is (\d+) and account id is (\d+)")
def enter(user_id,account_id):
    scc.user = user_operations.get_user_from_id(int(account_id), int(user_id), scc.headers)

@Then("their (\w+) should equal (\w+)")
def check_result(field_value, result):
    assert_equal(str(result),scc.user[str(field_name)])

控制台输出:

C:\Users\Front-End>nosetests --with-freshen -v features\
Retrieve an existing User: Get existing User from their ID ... UNDEFINED: "I hav
e the user where their id is '288' and account id is '57'" # features\get_user.f
eature:6

----------------------------------------------------------------------
Ran 1 test in 0.137s

OK (UNDEFINED=1)

有人能指出我做错了吗?干杯!

1 个答案:

答案 0 :(得分:1)

如果在@Given函数中使用(\ d +)...(\ d +)

,该功能应具有此语法(假设我的用户身份为288,帐号为57)

M.Harbaoui