added tests for fixture override

This commit is contained in:
Oleg Podsadny 2013-04-07 01:00:38 +02:00
parent 6d901125fc
commit 023f36c990
8 changed files with 57 additions and 1 deletions

View File

@ -1,3 +1,3 @@
"""Configuration for pytest runner.""" """Configuration for pytest runner."""
pytest_plugins = "pytester" pytest_plugins = 'pytester'

View File

View File

View File

@ -0,0 +1,6 @@
from pytest_bdd import given
@given('I have the overriden fixture')
def overridable():
return 'child'

View File

@ -0,0 +1,25 @@
"""Test givens declared in the base conftest and plugin files.
Check the parent givens are collected, override them locally.
"""
from pytest_bdd import given
@given('I have locally overriden fixture')
def overridable():
return 'local'
@given('I have locally overriden parent fixture')
def parent():
return 'local'
def test_override(overridable):
"""Test locally overriden fixture."""
assert overridable == 'local'
def test_parent(parent):
"""Test locally overriden parent fixture."""
assert parent == 'local'

View File

@ -0,0 +1,14 @@
"""Test givens declared in the base conftest and plugin files.
Check the parent givens are collected and overriden in the local conftest.
"""
def test_parent(parent):
"""Test parent given is collected."""
assert parent == 'parent'
def test_override(overridable):
"""Test the child conftest overriding the fixture."""
assert overridable == 'child'

11
tests/library/conftest.py Normal file
View File

@ -0,0 +1,11 @@
from pytest_bdd import given
@given('I have parent fixture')
def parent():
return 'parent'
@given('I have overridable parent fixture')
def overridable():
return 'parent'

View File