{"id":951,"hash":"e651f0efaefd22eb50ebe7737c9da23d3b9e2b81e99af4394d65eea77912456b","pattern":"“ indirect fixture” error using pytest. What is wrong?","full_message":"def fatorial(n):\n    if n <= 1:\n        return 1\n    else:\n        return n*fatorial(n - 1)\n\nimport pytest\n\n@pytest.mark.parametrize(\"entrada\",\"esperado\",[\n    (0,1),\n    (1,1),\n    (2,2),\n    (3,6),\n    (4,24),\n    (5,120)\n])\n\ndef testa_fatorial(entrada,esperado):\n    assert fatorial(entrada)  == esperado\n\nThe error:\n\n ERROR collecting Fatorial_pytest.py ____________________________________________________________________\nIn testa_fatorial: indirect fixture '(0, 1)' doesn't exist\n\nI dont know why I got \"indirect fixture”. Any idea?\nI am using python 3.7 and windows 10 64 bits.","ecosystem":"pypi","package_name":"python-3.x","package_version":null,"solution":"TL;DR -\n\nThe problem is with the line  \n\n@pytest.mark.parametrize(\"entrada\",\"esperado\",[ ... ])\n\nIt should be written as a comma-separated string:  \n\n@pytest.mark.parametrize(\"entrada, esperado\",[ ... ])\n\nYou got the indirect fixture because pytest couldn't unpack the given argvalues since it got a wrong argnames parameter. You need to make sure all parameters are written as one string.  \n\nPlease see the documentation:  \n\n  The builtin pytest.mark.parametrize decorator enables parametrization of arguments for a test function.\n\n  \n  Parameters:\n\n  1. argnames – a comma-separated string denoting one or more argument names,  or a list/tuple of argument strings.\n\n  2. argvalues – The list of argvalues determines how often a test is invoked\n  with different argument values.\n\nMeaning, you should write the arguments you want to parametrize as a single string and separate them using a comma. Therefore, your test should look like this:  \n\n@pytest.mark.parametrize(\"n, expected\", [\n    (0, 1),\n    (1, 1),\n    (2, 2),\n    (3, 6),\n    (4, 24),\n    (5, 120)\n])\ndef test_factorial(n, expected):\n    assert factorial(n) == expected","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/61047555/indirect-fixture-error-using-pytest-what-is-wrong","votes":65,"created_at":"2026-04-19T04:52:04.243920+00:00","updated_at":"2026-04-19T04:52:04.243920+00:00"}