From c081c5ee23200efbad96f20b766f2521272e96f6 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Wed, 18 Jan 2017 14:39:47 +0100 Subject: [PATCH] add example scripts for issue #519 --- testing/example_scripts/issue_519.py | 34 ++++++++++++++++++++++++++++ tox.ini | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 testing/example_scripts/issue_519.py diff --git a/testing/example_scripts/issue_519.py b/testing/example_scripts/issue_519.py new file mode 100644 index 00000000000..08a9e17d7c7 --- /dev/null +++ b/testing/example_scripts/issue_519.py @@ -0,0 +1,34 @@ + +import pytest +import pprint +def pytest_generate_tests(metafunc): + if 'arg1' in metafunc.fixturenames: + metafunc.parametrize("arg1", [ 'arg1v1', 'arg1v2' ], scope='module') + + if 'arg2' in metafunc.fixturenames: + metafunc.parametrize("arg2", [ 'arg2v1', 'arg2v2' ], scope='function') + +@pytest.fixture(scope='session') +def checked_order(): + order = [] + + yield order + pprint.pprint(order) + assert order == [] + + +@pytest.yield_fixture(scope='module') +def fix1(request, arg1, checked_order): + checked_order.append((request.node.name, 'fix1', arg1)) + yield 'fix1-' + arg1 + +@pytest.yield_fixture(scope='function') +def fix2(request, fix1, arg2, checked_order): + checked_order.append((request.node.name, 'fix2', arg2)) + yield 'fix2-' + arg2 + fix1 + +def test_one(fix2): + pass + +def test_two(fix2): + pass diff --git a/tox.ini b/tox.ini index c346b5682c2..e2495af4c66 100644 --- a/tox.ini +++ b/tox.ini @@ -192,7 +192,7 @@ rsyncdirs = tox.ini pytest.py _pytest testing python_files = test_*.py *_test.py testing/*/*.py python_classes = Test Acceptance python_functions = test -norecursedirs = .tox ja .hg cx_freeze_source +norecursedirs = .tox ja .hg cx_freeze_source testing/example_scripts xfail_strict=true filterwarnings = error