diff --git a/setup.py b/setup.py index dcf63f6fd..be38857b0 100644 --- a/setup.py +++ b/setup.py @@ -28,6 +28,7 @@ def main(): "mock", "nose", "requests", + "numpy", "xmlschema", ] }, diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index b4b10fcd2..ed7e715de 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -1113,6 +1113,9 @@ def fixture( ``fixture_`` and then use ``@pytest.fixture(name='')``. """ + if params is not None and not isinstance(params, (list, tuple)): + params = list(params) + fixture_function, arguments = _parse_fixture_args( callable_or_scope, *args, @@ -1134,8 +1137,6 @@ def fixture( 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) diff --git a/testing/python/fixtures.py b/testing/python/fixtures.py index f4dbfdf09..e0b464c96 100644 --- a/testing/python/fixtures.py +++ b/testing/python/fixtures.py @@ -4187,3 +4187,21 @@ def test_indirect_fixture_does_not_break_scope(testdir): ) result = testdir.runpytest() 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)