Casting fixture parameter to list at the beginning of parameter parsing.
This commit is contained in:
parent
bad4ffc3a7
commit
1f639e2c22
1
setup.py
1
setup.py
|
@ -28,6 +28,7 @@ def main():
|
||||||
"mock",
|
"mock",
|
||||||
"nose",
|
"nose",
|
||||||
"requests",
|
"requests",
|
||||||
|
"numpy",
|
||||||
"xmlschema",
|
"xmlschema",
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -1113,6 +1113,9 @@ def fixture(
|
||||||
``fixture_<fixturename>`` and then use
|
``fixture_<fixturename>`` and then use
|
||||||
``@pytest.fixture(name='<fixturename>')``.
|
``@pytest.fixture(name='<fixturename>')``.
|
||||||
"""
|
"""
|
||||||
|
if params is not None and not isinstance(params, (list, tuple)):
|
||||||
|
params = list(params)
|
||||||
|
|
||||||
fixture_function, arguments = _parse_fixture_args(
|
fixture_function, arguments = _parse_fixture_args(
|
||||||
callable_or_scope,
|
callable_or_scope,
|
||||||
*args,
|
*args,
|
||||||
|
@ -1134,8 +1137,6 @@ def fixture(
|
||||||
fixture_function
|
fixture_function
|
||||||
)
|
)
|
||||||
|
|
||||||
if params is not None and not isinstance(params, (list, tuple)):
|
|
||||||
params = list(params)
|
|
||||||
return FixtureFunctionMarker(scope, params, autouse, ids=ids, name=name)
|
return FixtureFunctionMarker(scope, params, autouse, ids=ids, name=name)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4187,3 +4187,21 @@ def test_indirect_fixture_does_not_break_scope(testdir):
|
||||||
)
|
)
|
||||||
result = testdir.runpytest()
|
result = testdir.runpytest()
|
||||||
result.assert_outcomes(passed=7)
|
result.assert_outcomes(passed=7)
|
||||||
|
|
||||||
|
|
||||||
|
def test_fixture_parametrization_nparray(testdir):
|
||||||
|
testdir.makepyfile(
|
||||||
|
"""
|
||||||
|
from numpy import linspace
|
||||||
|
from pytest import fixture
|
||||||
|
|
||||||
|
@fixture(params=linspace(1, 10, 10))
|
||||||
|
def value(request):
|
||||||
|
return request.param
|
||||||
|
|
||||||
|
def test_bug(value):
|
||||||
|
assert value == value
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
result = testdir.runpytest()
|
||||||
|
result.assert_outcomes(passed=10)
|
||||||
|
|
Loading…
Reference in New Issue