[pypy-commit] pypy default: Make these tests import even if 'hypothesis' is not available
arigo
pypy.commits at gmail.com
Sun Oct 15 16:25:30 EDT 2017
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r92769:f29e5fba625b
Date: 2017-10-15 22:24 +0200
http://bitbucket.org/pypy/pypy/changeset/f29e5fba625b/
Log: Make these tests import even if 'hypothesis' is not available
diff --git a/pypy/objspace/std/test/test_bytesobject.py b/pypy/objspace/std/test/test_bytesobject.py
--- a/pypy/objspace/std/test/test_bytesobject.py
+++ b/pypy/objspace/std/test/test_bytesobject.py
@@ -1,4 +1,3 @@
-from hypothesis import given, strategies, settings, example
from pypy.interpreter.error import OperationError
@@ -90,13 +89,19 @@
w_bytes = self.space.newbytes('abcd')
assert self.space.listview_bytes(w_bytes) == list("abcd")
- @given(strategies.binary(), strategies.integers(min_value=0, max_value=10),
- strategies.integers(min_value=-1, max_value=10))
- def test_hypo_index_find(self, u, start, len1):
+
+try:
+ from hypothesis import given, strategies
+except ImportError:
+ pass
+else:
+ @given(u=strategies.binary(),
+ start=strategies.integers(min_value=0, max_value=10),
+ len1=strategies.integers(min_value=-1, max_value=10))
+ def test_hypo_index_find(u, start, len1, space):
if start + len1 < 0:
return # skip this case
v = u[start : start + len1]
- space = self.space
w_u = space.wrap(u)
w_v = space.wrap(v)
expected = u.find(v, start, start + len1)
diff --git a/pypy/objspace/std/test/test_unicodeobject.py b/pypy/objspace/std/test/test_unicodeobject.py
--- a/pypy/objspace/std/test/test_unicodeobject.py
+++ b/pypy/objspace/std/test/test_unicodeobject.py
@@ -1,6 +1,5 @@
import py
import sys
-from hypothesis import given, strategies, settings, example
from pypy.interpreter.error import OperationError
@@ -34,13 +33,19 @@
space.w_unicode, "__new__", space.w_unicode, w_uni)
assert w_new is w_uni
- @given(strategies.text(), strategies.integers(min_value=0, max_value=10),
- strategies.integers(min_value=-1, max_value=10))
- def test_hypo_index_find(self, u, start, len1):
+
+try:
+ from hypothesis import given, strategies
+except ImportError:
+ pass
+else:
+ @given(u=strategies.text(),
+ start=strategies.integers(min_value=0, max_value=10),
+ len1=strategies.integers(min_value=-1, max_value=10))
+ def test_hypo_index_find(u, start, len1, space):
if start + len1 < 0:
return # skip this case
v = u[start : start + len1]
- space = self.space
w_u = space.wrap(u)
w_v = space.wrap(v)
expected = u.find(v, start, start + len1)
More information about the pypy-commit
mailing list