From f7d50dfa91e37aaffe566c400a9590b2c79cc50d Mon Sep 17 00:00:00 2001 From: Vasily Kuznetsov Date: Wed, 22 Jun 2016 17:24:55 +0200 Subject: [PATCH] Add a test for handling of dynamic requests for fixtures from other fixtures --- testing/python/setup_only.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/testing/python/setup_only.py b/testing/python/setup_only.py index 2508ca74e..11329775c 100644 --- a/testing/python/setup_only.py +++ b/testing/python/setup_only.py @@ -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' + ])