Add a test for handling of dynamic requests for fixtures from other fixtures

This commit is contained in:
Vasily Kuznetsov 2016-06-22 17:24:55 +02:00
parent c8c32fd9c0
commit f7d50dfa91
1 changed files with 22 additions and 0 deletions

View File

@ -157,3 +157,25 @@ def test_show_fixtures_with_parameter_ids(testdir, mode):
'SETUP S arg_same?spam?',
'SETUP S arg_same?ham?',
])
def test_dynamic_fixture_request(testdir):
p = testdir.makepyfile('''
import pytest
@pytest.fixture()
def dynamically_requested_fixture():
pass
@pytest.fixture()
def dependent_fixture(request):
request.getfuncargvalue('dynamically_requested_fixture')
def test_dyn(dependent_fixture):
pass
''')
result = testdir.runpytest('--setup-only', p)
assert result.ret == 0
result.stdout.fnmatch_lines([
'*SETUP F dynamically_requested_fixture',
'*TEARDOWN F dynamically_requested_fixture'
])