Skip to content

Commit 6d318dd

Browse files
add example scripts for issue #519
1 parent d15724f commit 6d318dd

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
@@ -172,7 +172,7 @@ rsyncdirs=tox.ini pytest.py _pytest testing
172172
python_files=test_*.py *_test.py testing/*/*.py
173173
python_classes=Test Acceptance
174174
python_functions=test
175-
norecursedirs = .tox ja .hg cx_freeze_source
175+
norecursedirs = .tox ja .hg cx_freeze_source testing/example_scripts
176176

177177

178178
[flake8]

0 commit comments

Comments
 (0)