Skip to content

Commit 4334ae1

Browse files
author
Sylvain MARIE
committed
Autouse fixtures are now correctly used. Fixes #114
1 parent 3ac9bb9 commit 4334ae1

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

pytest_cases/plugin.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,6 @@ def getfixtureclosure(fm, fixturenames, parentnode, ignore_args=()):
628628
else:
629629
# we cannot sort yet - merge the fixture names into the _init_fixnames
630630
merge(fixturenames, _init_fixnames)
631-
sorted_fixturenames = []
632631

633632
# Finally create the closure tree
634633
if _DEBUG:
@@ -666,8 +665,7 @@ def getfixtureclosure(fm, fixturenames, parentnode, ignore_args=()):
666665
# store_union_closure_in_node(fixturenames_closure_node, parentnode)
667666

668667
if LooseVersion(pytest.__version__) >= LooseVersion('3.7.0'):
669-
our_initial_names = sorted_fixturenames # initial_names
670-
return our_initial_names, fixturenames_closure_node, arg2fixturedefs
668+
return _init_fixnames, fixturenames_closure_node, arg2fixturedefs
671669
else:
672670
return fixturenames_closure_node, arg2fixturedefs
673671

pytest_cases/tests/cases/issues/__init__.py

Whitespace-only changes.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import pytest
2+
3+
used = False
4+
5+
6+
@pytest.fixture(autouse=True)
7+
def one():
8+
global used
9+
used = True
10+
pass
11+
12+
13+
@pytest.fixture(params=[1, 2])
14+
def two():
15+
pass
16+
17+
18+
def test_me(two):
19+
global used
20+
assert used

0 commit comments

Comments
 (0)