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

Support fuzz_one_input on instance methods #4060

Open
tybug opened this issue Jul 28, 2024 · 0 comments
Open

Support fuzz_one_input on instance methods #4060

tybug opened this issue Jul 28, 2024 · 0 comments
Labels
bug something is clearly wrong here

Comments

@tybug
Copy link
Member

tybug commented Jul 28, 2024

from hypothesis import *
from hypothesis import strategies as st

class A:
    @given(st.integers())
    def f(self, n):
        pass

a = A()
a.f() # works
a.f.hypothesis.fuzz_one_input(b"\x01") # fails with `TypeError: missing a required argument: 'self'`

HypothesisHandle.inner_test is a reference to the underlying A.f.__func__, so _get_fuzz_target doesn't know about the required self arg. We probably need to thread "you are an instance method, pass this additional arg when calling" into HypothesisHandle somehow.

fwiw I've worked around this locally, so no rush to fix. Just logging for whenever we get to it.

@tybug tybug added the bug something is clearly wrong here label Jul 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something is clearly wrong here
Projects
None yet
Development

No branches or pull requests

1 participant