Skip to content
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

Wrong "Recursion detected" in py.test traceback #70

Closed
pytestbot opened this issue Aug 31, 2011 · 5 comments
Closed

Wrong "Recursion detected" in py.test traceback #70

pytestbot opened this issue Aug 31, 2011 · 5 comments
Labels
type: bug problem that needs to be addressed

Comments

@pytestbot
Copy link
Contributor

Originally reported by: BitBucket: pchambon, GitHub: pchambon


Hello,

I've just spent a hell of a time trying to debug a "Recursion detected (same locals & position)" that my test suite raised, to eventually see that it was not a python error, but a pytest problem while collecting test results.

Due to the "magic" used in the program (decorator module), pytest thought there was a recursion, whereas several functions were simply using generated wrappers to preserve their signature while decorating.

The main problem is actually that the real exception (a runtime error, in the test sample) got hidden because of that "recursion detected" (see output below), thus deceiving me about the real problem. Having a fix to ignore "" entries, when detecting traceback recursions, would be neat too.

CF attached sample to reproduce the error ("decorator" module must tbe installed).

cheers,
P. Chambon

#!python

[pascal@charlie ~/test]$ py.test weird_recursion.py
====================================== test session starts =======================================
platform freebsd8 -- Python 2.6.6 -- pytest-2.0.3
collected 0 items / 1 errors

============================================= ERRORS =============================================
______________________________ ERROR collecting weird_recursion.py _______________________________
weird_recursion.py:32: in <module>
>   test_tolkien_weird_recursivity()
weird_recursion.py:29: in test_tolkien_weird_recursivity
>           retrieve_stuffs("0654345654123")
<string>:2: in retrieve_stuffs
>   ???
weird_recursion.py:11: in mymiddleware
>           res = func(*args, **kwargs)
<string>:2: in retrieve_stuffs
>   ???
!!! Recursion detected (same locals & position)
---------------------------------------- Captured stderr -----------------------------------------
NOW WE RAISE ERROR
==================================== 1 error in 0.15 seconds =====================================

@pytestbot
Copy link
Contributor Author

Original comment by Ronny Pfannschmidt (BitBucket: RonnyPfannschmidt, GitHub: RonnyPfannschmidt):


it seems that FunctionMaker of the decorator package generates code + code objects with properties that end up looking exactly like recursion even if they are not

im not sure how to work around that, and if we even should try to work around that

@pytestbot
Copy link
Contributor Author

Original comment by BitBucket: pchambon, GitHub: pchambon:


Indeed, but there would be something to do in terms of clarity:

  • replacing "recursion detected" by a more relevant detail, eg. "Potential recursion detected by pytest - truncating traceback" ?
  • letting at the bottom, in red color, the actual exception that caused the traceback (it gets swallowed by the traceback truncation, in my example)

Then people would not believe (as I did) that the recursion has been detected by the python runtime.

@pytestbot
Copy link
Contributor Author

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


We could at least adapt the error message, indeed. Is there really no way to recognizethese decorators?

@pytestbot
Copy link
Contributor Author

Original comment by Ronny Pfannschmidt (BitBucket: RonnyPfannschmidt, GitHub: RonnyPfannschmidt):


fixed in pylib default now

@pytestbot
Copy link
Contributor Author

Original comment by Anonymous:


1000 thanks B-)

@pytestbot pytestbot added the type: bug problem that needs to be addressed label Jun 15, 2015
blueyed added a commit that referenced this issue Nov 20, 2019
This is necessary for when using e.g. `no_fnmatch_line` after it.
Factor it out into `_fail`.

(cherry picked from commit aade7ed)

Ref: #5914 (comment)
vinaycalastry pushed a commit to vinaycalastry/pytest that referenced this issue Dec 11, 2019
This is necessary for when using e.g. `no_fnmatch_line` after it.
Factor it out into `_fail`.

(cherry picked from commit aade7ed)

Ref: pytest-dev#5914 (comment)
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