Skip to content

Commit 0e633a7

Browse files
author
Sylvain MARIE
committed
Fixed #52
1 parent b5f45a6 commit 0e633a7

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

pytest_cases/main_fixtures.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,16 @@ def pytest_fixture_plus(scope="function",
468468
# 'name' argument is not supported in this old version, use the __name__ trick.
469469
fixture_func.__name__ = name
470470

471+
# if unpacking is requested, do it first
472+
if unpack_into is not None:
473+
# get the future fixture name if needed
474+
if name is None:
475+
name = fixture_func.__name__
476+
477+
# get caller module to create the symbols
478+
caller_module = get_caller_module(frame_offset=2)
479+
_unpack_fixture(caller_module, unpack_into, name)
480+
471481
# (1) Collect all @pytest.mark.parametrize markers (including those created by usage of @cases_data)
472482
parametrizer_marks = get_pytest_parametrize_marks(fixture_func)
473483
if len(parametrizer_marks) < 1:
@@ -577,16 +587,6 @@ def _get_arguments(*args, **kwargs):
577587

578588
return args, kwargs
579589

580-
# if unpacking is requested, do it here
581-
if unpack_into is not None:
582-
# get the future fixture name if needed
583-
if name is None:
584-
name = fixture_func.__name__
585-
586-
# get caller module to create the symbols
587-
caller_module = get_caller_module(frame_offset=2)
588-
_unpack_fixture(caller_module, unpack_into, name)
589-
590590
# --Finally create the fixture function, a wrapper of user-provided fixture with the new signature
591591
if not isgeneratorfunction(fixture_func):
592592
# normal function with return statement
@@ -864,7 +864,7 @@ def _new_fixture(request, **all_fixtures):
864864

865865
# if unpacking is requested, do it here
866866
if unpack_into is not None:
867-
_unpack_fixture(caller_module, unpack_into, name)
867+
_unpack_fixture(caller_module, argnames=unpack_into, fixture=name)
868868

869869
return fix
870870

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from pytest_cases import pytest_fixture_plus
2+
3+
4+
@pytest_fixture_plus(unpack_into="foo,bar")
5+
def foobar():
6+
return "blah", "whatever"
7+
8+
9+
def test_stuff(foo, bar):
10+
assert foo == "blah" and bar == "whatever"

0 commit comments

Comments
 (0)