You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
throws InvalidArgument: test() got an unexpected keyword argument 'a', from a=integers() in @given.
Is there a way to do this? I see some tests relating to pos-only args, so I suspect this has been though about, but I also haven't found examples of this (somewhat hard to search for).
The text was updated successfully, but these errors were encountered:
It looks like you've pasted the first example test twice, so I'm not sure what's different in the second? If it's meant to show @given(st.integers()), then you'll have two problems: no argument given for b, and passing a by keyword when it's a positional-only argument.
Unfortunately we had to lock in the details for how Hypothesis translates the arguments to @given() into arguments to your test function back when we supported Python 2, before positional-only or even keyword-only arguments (or inspect.Signature.bind()) existed. As a result, I've been unable to support generating positional-only arguments using Hypothesis - although we can now generate the other parameters for a test function-or-method which has some posonly params - and we've also had to exclude mixing positional and keyword arguments to the @given() decorator.
While this is definitely not ideal, restricting the signatures of supported test functions is a relatively small cost compared to breaking many existing tests which would change the signature binding semantics. For what it's worth, I'm not convinced that offering more power is a good tradeoff against simplicity either 😕
Ooof, my bad. The example that raises "InvalidArgument: test() got an unexpected keyword argument 'a', from a=integers() in @given" should've indeed been this:
Hi and thanks for the hard work on hypothesis, it's been super useful already.
I can't seem to use
@given
with a function that has pos-only args:raises
InvalidArgument: positional arguments to @given are not supported with varargs, varkeywords, positional-only, or keyword-only arguments
while
throws
InvalidArgument: test() got an unexpected keyword argument 'a', from
a=integers()in @given
.Is there a way to do this? I see some tests relating to pos-only args, so I suspect this has been though about, but I also haven't found examples of this (somewhat hard to search for).
The text was updated successfully, but these errors were encountered: