[pypy-commit] pypy default: Playing around with hypothesis
arigo
pypy.commits at gmail.com
Wed Mar 9 11:40:44 EST 2016
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r82914:d994482a6040
Date: 2016-03-09 17:40 +0100
http://bitbucket.org/pypy/pypy/changeset/d994482a6040/
Log: Playing around with hypothesis
diff --git a/rpython/rlib/test/test_rbigint.py b/rpython/rlib/test/test_rbigint.py
--- a/rpython/rlib/test/test_rbigint.py
+++ b/rpython/rlib/test/test_rbigint.py
@@ -15,6 +15,8 @@
from rpython.rtyper.test.test_llinterp import interpret
from rpython.translator.c.test.test_standalone import StandaloneTests
+from hypothesis import given, strategies
+
long_vals_not_too_big = range(17) + [
37, 50,
127, 128, 129, 511, 512, 513, sys.maxint, sys.maxint + 1,
@@ -967,6 +969,14 @@
py.test.raises(InvalidSignednessError, i.tobytes, 3, 'little', signed=False)
py.test.raises(OverflowError, i.tobytes, 2, 'little', signed=True)
+ @given(strategies.binary(), strategies.booleans(), strategies.booleans())
+ def test_frombytes_tobytes_hypothesis(self, s, big, signed):
+ # check the roundtrip from binary strings to bigints and back
+ byteorder = 'big' if big else 'little'
+ bigint = rbigint.frombytes(s, byteorder=byteorder, signed=signed)
+ t = bigint.tobytes(len(s), byteorder=byteorder, signed=signed)
+ assert s == t
+
class TestTranslated(StandaloneTests):
More information about the pypy-commit
mailing list