pytest parametrize: function uses no argument (tested)
In test_x: function uses no argument 'value' means a name in @pytest.mark.parametrize("value, ...") is not a parameter of the test function: a typo, or names separated by spaces instead of commas. The names string must match the function's argument names exactly.
@pytest.mark.parametrize errors are raised while pytest collects the file, so one bad decorator stops the whole file (and the run exits with code 2). Each case below was run on pytest 9.1.1.
1. "function uses no argument": the names do not match the parameters
$ cat test_a.py
import pytest
@pytest.mark.parametrize("value, expected", [(1, 2), (2, 3)])
def test_inc(val, expected):
assert val + 1 == expected
$ pytest -q | grep "uses no argument" | head -1; pytest -q | tail -1
In test_a.py::test_inc: function uses no argument 'value'
1 error in 0.07s
The first string of parametrize must use the exact parameter names of the test function. Here the decorator says value but the function takes val. Rename one so they match:
$ pytest -q | tail -1
2 passed in 0.00s
2. Names separated by spaces instead of commas
$ cat test_d.py
import pytest
@pytest.mark.parametrize(["a", "b"], [(1, 2)])
def test_x(a, b):
assert a < b
@pytest.mark.parametrize("a b", [(1, 2)])
def test_y(a, b):
pass
$ pytest -q | grep "uses no argument" | head -1
In test_d.py::test_y: function uses no argument 'a b'
Names in the string are split on commas only, so "a b" is one name, 'a b', which no function can take. Use "a, b" (spaces after commas are fine, as in block 1) or a list ["a", "b"] as in test_x above.
3. The opposite: a function argument that is not parametrized
$ cat test_c.py
import pytest
@pytest.mark.parametrize("n", [1, 2])
def test_x(n, m):
pass
$ pytest -q | grep -E "^E |^ERROR"
E fixture 'm' not found
E fixture 'm' not found
ERROR test_c.py::test_x[1]
ERROR test_c.py::test_x[2]
Every function argument not listed in parametrize must be a fixture, so m gives fixture 'm' not found, once per generated test. Add it to the names string, give it a default value, or define a fixture.
4. "the number of names (2) must be equal to the number of values (3)"
$ cat test_b.py
import pytest
@pytest.mark.parametrize("a,b", [(1, 2, 3)])
def test_x(a, b):
pass
$ pytest -q | sed -n "4,7p"
test_b.py::test_x: in "parametrize" the number of names (2):
['a', 'b']
must be equal to the number of values (3):
(1, 2, 3)
Each value tuple must have one item per name.
5. TypeError: object of type 'int' has no len()
$ cat test_e.py
import pytest
@pytest.mark.parametrize("a,b", [1, 2])
def test_x(a, b):
pass
$ pytest -q | grep "^E "
E TypeError: object of type 'int' has no len()
With two or more names, every value must be a tuple (or list). A bare 1 cannot be unpacked into a, b; write [(1, 2)].
6. One name with tuple values is fine
$ cat test_h.py
import pytest
@pytest.mark.parametrize("x", [(1, 2), (3, 4)])
def test_x(x):
print(repr(x))
$ pytest -q -s | head -2
(1, 2)
.(3, 4)
With a single name, each value is passed as is, so x receives the whole tuple (1, 2). If you expected two arguments, list both names.
7. "duplicate parametrization of 'a'"
$ cat test_f.py
import pytest
@pytest.mark.parametrize("a", [1])
@pytest.mark.parametrize("a", [2])
def test_x(a):
pass
$ pytest -q | grep duplicate | head -1
test_f.py::test_x: duplicate parametrization of 'a'
Stacked parametrize decorators multiply (every combination), so each must use different names. Put all values for a in one decorator: parametrize("a", [1, 2]).
8. indirect=True needs a fixture of that name
$ cat test_g.py
import pytest
@pytest.mark.parametrize("user", ["bob"], indirect=True)
def test_x(user):
pass
$ pytest -q | grep "not found"
E fixture 'user' not found
With indirect=True the values go to a fixture via request.param instead of directly to the test, so the fixture must exist:
$ cat test_g.py
import pytest
@pytest.fixture
def user(request):
return {"name": request.param}
@pytest.mark.parametrize("user", ["bob"], indirect=True)
def test_x(user):
assert user["name"] == "bob"
$ pytest -q | tail -1
1 passed in 0.00s
Related: pytest exit codes, pytest Failed: DID NOT RAISE.
Frequently asked questions
What does function uses no argument mean in pytest?
A name in the parametrize names string is not an argument of the test function, usually a typo or space-separated names like 'a b' instead of 'a, b'.
How do I fix the number of names must be equal to the number of values?
Give every value tuple exactly one item per name, e.g. parametrize('a, b', [(1, 2), (3, 4)]).
Can I use parametrize twice on the same argument?
No, that raises duplicate parametrization. Stacked parametrize decorators must use different names; they produce every combination.
Written with AI assistance. Measured on 2026-10-23 with pytest 9.1.1 on Python 3.13.5 in a clean virtualenv. Each block was run verbatim and the output pasted unedited. PlainHeaders is our extension; Python and pytest are free.