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

[BUG] astroid crashes with RecursionError in a pytest session if schemathesis is installed #2170

Open
3 tasks done
jherbel opened this issue May 10, 2024 · 1 comment
Open
3 tasks done
Assignees
Labels
Status: Needs Triage Requires initial assessment to categorize and prioritize Type: Bug Errors or unexpected behavior

Comments

@jherbel
Copy link

jherbel commented May 10, 2024

Checklist

  • I checked the FAQ section of the documentation
  • I looked for similar issues in the issue tracker
  • I am using the latest version of Schemathesis

Describe the bug

When using astroid in pytest session with schemathesis installed, I get a RecursionError. Without schemathesis, I don't.

To Reproduce

Run pytest on the following file:

import astroid

def test_something() -> None:
    astroid.parse("123")

Result without schemathesis:

$ pytest /home/joerg/tmp/test_with_astroid.py 
=================================== test session starts ===================================
platform linux -- Python 3.12.3, pytest-8.1.1, pluggy-1.5.0
rootdir: /home/joerg
plugins: anyio-4.3.0, hypothesis-6.100.6, subtests-0.7.0
collected 1 item                                                                          

tmp/test_with_astroid.py .                                                          [100%]

==================================== 1 passed in 0.28s ====================================

Result with schemathesis:

$ pytest /home/joerg/tmp/test_with_astroid.py 
=================================== test session starts ===================================
platform linux -- Python 3.12.3, pytest-8.1.1, pluggy-1.5.0
rootdir: /home/joerg
plugins: anyio-4.3.0, hypothesis-6.100.6, schemathesis-3.27.1, subtests-0.7.0
collected 1 item                                                                          

tmp/test_with_astroid.py F                                                          [100%]

======================================== FAILURES =========================================
_____________________________________ test_something ______________________________________

    def test_something() -> None:
>   	astroid.parse("123")

tmp/test_with_astroid.py:4: 
...
self = <Const l.0 at 0x7fe6c1531e20>, proxied = None

    def __init__(self, proxied: nodes.ClassDef | None) -> None:
>       super().__init__(proxied)
E       RecursionError: maximum recursion depth exceeded

.pyenv/versions/3.12.3/lib/python3.12/site-packages/astroid/bases.py:342: RecursionError
==================================== warnings summary =====================================
tmp/test_with_astroid.py::test_something
  /home/joerg/.pyenv/versions/3.12.3/lib/python3.12/site-packages/_pytest/python.py:1772: PluggyTeardownRaisedWarning: A plugin raised an exception during an old-style hookwrapper teardown.
  Plugin: schemathesis, Hook: pytest_pyfunc_call
  RecursionError: maximum recursion depth exceeded
  For more information see https://pluggy.readthedocs.io/en/stable/api_reference.html#pluggy.PluggyTeardownRaisedWarning
    self.ihook.pytest_pyfunc_call(pyfuncitem=self)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================= short test summary info =================================
FAILED tmp/test_with_astroid.py::test_something - RecursionError: maximum recursion depth exceeded
============================== 1 failed, 1 warning in 15.09s ==============================

I don't use any API schema.

Expected behavior

astroid works in a pytest session if schemathesis is installed.

Environment

- OS: Linux
- Python version: 3.12.3
- Schemathesis version: 3.27.1

I also opened an issue with astroid: pylint-dev/astroid#2427

@Stranger6667
Copy link
Member

Hi @jherbel

It looks very similar to #1745, however, this problem fails with recursion instead of an infinite loop. Not sure if the underlying cause is the same as in pylint-dev/astroid#2191 but surely needs to be investigated deeper

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Triage Requires initial assessment to categorize and prioritize Type: Bug Errors or unexpected behavior
Projects
None yet
Development

No branches or pull requests

2 participants