Author: Carl Friedrich Bolz <[email protected]>
Branch: hypothesis-apptest
Changeset: r85075:4270eecf42e5
Date: 2016-06-09 18:21 +0200
http://bitbucket.org/pypy/pypy/changeset/4270eecf42e5/
Log: support for more than one argument
diff --git a/pypy/tool/pytest/appsupport.py b/pypy/tool/pytest/appsupport.py
--- a/pypy/tool/pytest/appsupport.py
+++ b/pypy/tool/pytest/appsupport.py
@@ -11,16 +11,19 @@
# ____________________________________________________________
-def app_hypothesis_given(arg1):
+def app_hypothesis_given(*args):
from hypothesis import given
+ from hypothesis import strategies
def decorator(func):
- @given(arg1)
- def inner(space, original, arg1):
- return original(space, space.wrap(arg1))
+ tuple_stategy = strategies.tuples(*args)
+ @given(tuple_stategy)
+ def inner(space, original, arg_tuple):
+ args_w = [space.wrap(arg) for arg in arg_tuple]
+ return original(space, *args_w)
- @given(arg1)
- def appdirect(arg1):
- return func(arg1)
+ @given(tuple_stategy)
+ def appdirect(arg_tuple):
+ return func(*arg_tuple)
appdirect.hypothesis_inner = inner
appdirect.original_function = func
return appdirect
diff --git a/pypy/tool/pytest/test/test_hypothesis.py
b/pypy/tool/pytest/test/test_hypothesis.py
--- a/pypy/tool/pytest/test/test_hypothesis.py
+++ b/pypy/tool/pytest/test/test_hypothesis.py
@@ -9,4 +9,11 @@
assert 1.0 <= f <= 2.0
assert f == f # not a NaN
+@app_hypothesis_given(strategies.floats(min_value=1.0, max_value=2.0),
strategies.floats(min_value=1.0, max_value=3.0))
+def app_test_2_floats(f, g):
+ assert 1.0 <= f <= 2.0
+ assert 1.0 <= g <= 3.0
+ assert f == f # not a NaN
+ assert g == g # not a NaN
+
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit