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

RecursionError when inspect.getfullargspec is mocked #160

Open
fornellas opened this issue Apr 16, 2020 · 0 comments
Open

RecursionError when inspect.getfullargspec is mocked #160

fornellas opened this issue Apr 16, 2020 · 0 comments
Labels
bug Something isn't working help wanted Extra attention is needed mock(_async)_callable
Milestone

Comments

@fornellas
Copy link
Contributor

Given:

import inspect
import subprocess
from testslide.dsl import context

class SomeClass:
  @staticmethod
  def method():
    inspect.getfullargspec(subprocess.Popen.__init__)

@context
def top(context):
  @context.example
  def repro(self):
    self.mock_callable(inspect, "getfullargspec").to_call_original()
    SomeClass.method()

When:

$ python -m testslide.cli --show-testslide-stack-trace repro.py

Then:

top
  repro: RecursionError: maximum recursion depth exceeded while calling a Python object

Failures:

  1) top: repro
    1) RecursionError: maximum recursion depth exceeded while calling a Python object
      File "testslide/runner.py", line 578, in run
        self._run_example(example)
      File "testslide/runner.py", line 562, in _run_example
        _ExampleRunner(example, self.formatter).run()
      File "testslide/__init__.py", line 441, in run
        self._sync_run_all_hooks_and_example(context_data)
      File "testslide/__init__.py", line 413, in _sync_run_all_hooks_and_example
        aggregated_exceptions.raise_correct_exception()
      File "testslide/__init__.py", line 199, in raise_correct_exception
        raise self.exceptions[0]
      File "testslide/__init__.py", line 183, in catch
        yield
      File "testslide/__init__.py", line 404, in _sync_run_all_hooks_and_example
        self._fail_if_coroutine_function(self.example.code, context_data)
      File "testslide/__init__.py", line 376, in _fail_if_coroutine_function
        return func(*args, **kwargs)
      File "repro.py", line 15, in repro
        SomeClass.method()
      File "repro.py", line 8, in method
        inspect.getfullargspec(subprocess.Popen.__init__)
      File "testslide/lib.py", line 131, in with_sig_check
        _validate_function_signature(callable_template, args, kwargs)
      File "testslide/lib.py", line 56, in _validate_function_signature
        argspec = inspect.getfullargspec(callable_template)
      File "testslide/lib.py", line 131, in with_sig_check
        _validate_function_signature(callable_template, args, kwargs)
      File "testslide/lib.py", line 56, in _validate_function_signature
        argspec = inspect.getfullargspec(callable_template)
      (last 2 lines repeat a lot)
      File "testslide/lib.py", line 125, in with_sig_check
        signature.bind(*args, **kwargs)
      File "/home/fornellas/.pyenv/versions/3.8.0/lib/python3.8/inspect.py", line 3025, in bind
        return self._bind(args, kwargs)
      File "/home/fornellas/.pyenv/versions/3.8.0/lib/python3.8/inspect.py", line 2892, in _bind
        arguments = OrderedDict()

Finished 1 example(s) in 0.8s: .
  Failed:  1

TestSlide uses inspect.getfullargspec internally, and somehow, the mock is interfering with it.

@fornellas fornellas added bug Something isn't working help wanted Extra attention is needed mock(_async)_callable labels Apr 16, 2020
@fornellas fornellas changed the title RecursionError when inspect.getfullargspec RecursionError when inspect.getfullargspec is mocked Apr 16, 2020
@fornellas fornellas added this to the Type Checking milestone Apr 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed mock(_async)_callable
Projects
None yet
Development

No branches or pull requests

1 participant