Skip to content

Parametrization leads to RuntimeError: maximum recursion depth exceeded #323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pytestbot opened this issue Jun 25, 2013 · 2 comments
Closed
Labels
type: bug problem that needs to be addressed

Comments

@pytestbot
Copy link
Contributor

Originally reported by: Anonymous


Here is the script to reproduce the bug:

#!python

import pytest

@pytest.fixture(scope='module', params=range(966))
def foo(request):
    return request.param

def test_it(foo):
    pass

And here is the result I get:

$ py.test test.py
========================================================================== test session starts ===========================================================================
platform linux2 -- Python 3.1.2 -- pytest-2.3.4 -- /usr/bin/python3
collecting 966 itemsINTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/usr/local/lib/python3.1/dist-packages/_pytest/main.py", line 81, in wrap_session
INTERNALERROR>     doit(config, session)
INTERNALERROR>   File "/usr/local/lib/python3.1/dist-packages/_pytest/main.py", line 112, in _main
INTERNALERROR>     config.hook.pytest_collection(session=session)
INTERNALERROR>   File "/usr/local/lib/python3.1/dist-packages/_pytest/core.py", line 422, in __call__
INTERNALERROR>     return self._docall(methods, kwargs)
INTERNALERROR>   File "/usr/local/lib/python3.1/dist-packages/_pytest/core.py", line 433, in _docall
INTERNALERROR>     res = mc.execute()
INTERNALERROR>   File "/usr/local/lib/python3.1/dist-packages/_pytest/core.py", line 351, in execute
INTERNALERROR>     res = method(**kwargs)
INTERNALERROR>   File "/usr/local/lib/python3.1/dist-packages/_pytest/main.py", line 116, in pytest_collection
INTERNALERROR>     return session.perform_collect()
INTERNALERROR>   File "/usr/local/lib/python3.1/dist-packages/_pytest/main.py", line 467, in perform_collect
INTERNALERROR>     config=self.config, items=items)
INTERNALERROR>   File "/usr/local/lib/python3.1/dist-packages/_pytest/core.py", line 422, in __call__
INTERNALERROR>     return self._docall(methods, kwargs)
INTERNALERROR>   File "/usr/local/lib/python3.1/dist-packages/_pytest/core.py", line 433, in _docall
INTERNALERROR>     res = mc.execute()
INTERNALERROR>   File "/usr/local/lib/python3.1/dist-packages/_pytest/core.py", line 351, in execute
INTERNALERROR>     res = method(**kwargs)
INTERNALERROR>   File "/usr/local/lib/python3.1/dist-packages/_pytest/python.py", line 1511, in pytest_collection_modifyitems
INTERNALERROR>     items[:] = parametrize_sorted(items, set(), {}, 0)
INTERNALERROR>   File "/usr/local/lib/python3.1/dist-packages/_pytest/python.py", line 1715, in parametrize_sorted
INTERNALERROR>     olditems = parametrize_sorted(olditems, ignore, cache, scopenum+1)
INTERNALERROR>   File "/usr/local/lib/python3.1/dist-packages/_pytest/python.py", line 1710, in parametrize_sorted
INTERNALERROR>     newignore, cache, scopenum)
...
INTERNALERROR>   File "/usr/local/lib/python3.1/dist-packages/_pytest/python.py", line 1698, in parametrize_sorted
INTERNALERROR>     argparamlist = getfuncargparams(item, ignore, scopenum, cache)
INTERNALERROR>   File "/usr/local/lib/python3.1/dist-packages/_pytest/python.py", line 1733, in getfuncargparams
INTERNALERROR>     if key in ignore:
INTERNALERROR> RuntimeError: maximum recursion depth exceeded

============================================================================  in 1.85 seconds ============================================================================

The test runs well when scope='function' or a number of parameters < 966


@pytestbot
Copy link
Contributor Author

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


fix issue323 - parametrize() of many module-scoped params

@pytestbot
Copy link
Contributor Author

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


fix issue396 -- properly sort tests using class-scoped parametrization

also refix issue323 in a better way to avoid recursion for the fixture-grouping
algorithm alltogether.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

1 participant