Skip to content

Commit c081c5e

Browse files
add example scripts for issue #519
1 parent 3dcdaab commit c081c5e

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

testing/example_scripts/issue_519.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
import pytest
3+
import pprint
4+
def pytest_generate_tests(metafunc):
5+
if 'arg1' in metafunc.fixturenames:
6+
metafunc.parametrize("arg1", [ 'arg1v1', 'arg1v2' ], scope='module')
7+
8+
if 'arg2' in metafunc.fixturenames:
9+
metafunc.parametrize("arg2", [ 'arg2v1', 'arg2v2' ], scope='function')
10+
11+
@pytest.fixture(scope='session')
12+
def checked_order():
13+
order = []
14+
15+
yield order
16+
pprint.pprint(order)
17+
assert order == []
18+
19+
20+
@pytest.yield_fixture(scope='module')
21+
def fix1(request, arg1, checked_order):
22+
checked_order.append((request.node.name, 'fix1', arg1))
23+
yield 'fix1-' + arg1
24+
25+
@pytest.yield_fixture(scope='function')
26+
def fix2(request, fix1, arg2, checked_order):
27+
checked_order.append((request.node.name, 'fix2', arg2))
28+
yield 'fix2-' + arg2 + fix1
29+
30+
def test_one(fix2):
31+
pass
32+
33+
def test_two(fix2):
34+
pass

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ rsyncdirs = tox.ini pytest.py _pytest testing
192192
python_files = test_*.py *_test.py testing/*/*.py
193193
python_classes = Test Acceptance
194194
python_functions = test
195-
norecursedirs = .tox ja .hg cx_freeze_source
195+
norecursedirs = .tox ja .hg cx_freeze_source testing/example_scripts
196196
xfail_strict=true
197197
filterwarnings =
198198
error

0 commit comments

Comments
 (0)