示例#1
0
文件: test_given.py 项目: ldiary/bdd
"""Given tests."""
import pytest

from bdd import given, then, scenario
from bdd.steps import StepError


@given("I have foo")
def foo():
    return "foo"

given("I have alias for foo", fixture="foo")
given("I have an alias to the root fixture", fixture="root")


@given("I have session foo", scope='session')
def session_foo():
    return "session foo"


@scenario('given.feature', 'Test reusing local fixture')
def test_given_with_fixture():
    pass


@scenario('given.feature', 'Test reusing root fixture')
def test_root_alias():
    pass


@scenario('given.feature', 'Test session given')
示例#2
0
文件: test_reuse.py 项目: ldiary/bdd
@scenario(
    'reuse.feature',
    'Given and when using the same fixture should not evaluate it twice',
)
def test_reuse():
    pass


@given('I have an empty list')
def empty_list():
    return []


@given('I have a fixture (appends 1 to a list)')
def appends_1(empty_list):
    empty_list.append(1)
    return empty_list

given('I have a fixture (appends 1 to a list) in reuse syntax', fixture='appends_1')


@when('I use this fixture')
def use_fixture(appends_1):
    pass


@then('my list should be [1]')
def list_should_be_1(appends_1):
    assert appends_1 == [1]