Skip to content

Commit

Permalink
Merge pull request #3389 from Zac-HD/rip-out-argspec
Browse files Browse the repository at this point in the history
Fix `@example()`/`@given()` argument-handling inconsistencies
  • Loading branch information
Zac-HD committed Jul 5, 2022
2 parents 272e77d + 5e10e12 commit 234bdac
Show file tree
Hide file tree
Showing 11 changed files with 163 additions and 155 deletions.
Expand Up @@ -24,7 +24,7 @@ When using a @given decorator, any arguments that are not provided in the @given
will be left visible in the final function:

```python
from inspect import getargspec
from inspect import signature

from hypothesis import given, strategies as st

Expand All @@ -34,13 +34,13 @@ def test_stuff(a, b, c, d):
pass


print(getargspec(test_stuff))
print(signature(test_stuff))
```

This then outputs the following:

```
ArgSpec(args=['b', 'd'], varargs=None, keywords=None, defaults=None)
<Signature (b, d)>
```

We've hidden the arguments 'a' and 'c', but the unspecified arguments 'b' and 'd'
Expand All @@ -64,7 +64,7 @@ def test_stuff(a, stuff):
assert stuff == "kittens"
```

This also works if we want to use @given with positional arguments:
This also works if we want to use @given with positional arguments:

```python
from pytest import fixture
Expand Down
5 changes: 5 additions & 0 deletions hypothesis-python/RELEASE.rst
@@ -0,0 +1,5 @@
RELEASE_TYPE: patch

This patch fixes some inconsistency between argument handling for
:func:`@example <hypothesis.example>` and :func:`@given <hypothesis.given>`
(:issue:`2706 <2706#issuecomment-1168363177>`).

0 comments on commit 234bdac

Please sign in to comment.