[pypy-commit] pypy default: Check behaviour of bytearray as well
rlamy
pypy.commits at gmail.com
Wed Nov 8 13:17:13 EST 2017
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch:
Changeset: r92975:461d62b49f22
Date: 2017-11-08 18:16 +0000
http://bitbucket.org/pypy/pypy/changeset/461d62b49f22/
Log: Check behaviour of bytearray as well
diff --git a/extra_tests/test_bytes.py b/extra_tests/test_bytes.py
--- a/extra_tests/test_bytes.py
+++ b/extra_tests/test_bytes.py
@@ -1,25 +1,27 @@
from hypothesis import strategies as st
from hypothesis import given, example
- at given(st.binary(), st.binary(), st.binary())
+st_bytestring = st.binary() | st.binary().map(bytearray)
+
+ at given(st_bytestring, st_bytestring, st_bytestring)
def test_find(u, prefix, suffix):
s = prefix + u + suffix
assert 0 <= s.find(u) <= len(prefix)
assert s.find(u, len(prefix), len(s) - len(suffix)) == len(prefix)
- at given(st.binary(), st.binary(), st.binary())
+ at given(st_bytestring, st_bytestring, st_bytestring)
def test_index(u, prefix, suffix):
s = prefix + u + suffix
assert 0 <= s.index(u) <= len(prefix)
assert s.index(u, len(prefix), len(s) - len(suffix)) == len(prefix)
- at given(st.binary(), st.binary(), st.binary())
+ at given(st_bytestring, st_bytestring, st_bytestring)
def test_rfind(u, prefix, suffix):
s = prefix + u + suffix
assert s.rfind(u) >= len(prefix)
assert s.rfind(u, len(prefix), len(s) - len(suffix)) == len(prefix)
- at given(st.binary(), st.binary(), st.binary())
+ at given(st_bytestring, st_bytestring, st_bytestring)
def test_rindex(u, prefix, suffix):
s = prefix + u + suffix
assert s.rindex(u) >= len(prefix)
@@ -34,20 +36,20 @@
start = max(start + len(u), 0)
return start, end
- at given(st.binary(), st.binary())
+ at given(st_bytestring, st_bytestring)
def test_startswith_basic(u, v):
assert u.startswith(v) is (u[:len(v)] == v)
@example(b'x', b'', 1)
@example(b'x', b'', 2)
- at given(st.binary(), st.binary(), st.integers())
+ at given(st_bytestring, st_bytestring, st.integers())
def test_startswith_start(u, v, start):
expected = u[start:].startswith(v) if v else (start <= len(u))
assert u.startswith(v, start) is expected
@example(b'x', b'', 1, 0)
@example(b'xx', b'', -1, 0)
- at given(st.binary(), st.binary(), st.integers(), st.integers())
+ at given(st_bytestring, st_bytestring, st.integers(), st.integers())
def test_startswith_3(u, v, start, end):
if v:
expected = u[start:end].startswith(v)
@@ -56,7 +58,7 @@
expected = start0 <= len(u) and start0 <= end0
assert u.startswith(v, start, end) is expected
- at given(st.binary(), st.binary())
+ at given(st_bytestring, st_bytestring)
def test_endswith_basic(u, v):
if len(v) > len(u):
assert u.endswith(v) is False
@@ -65,14 +67,14 @@
@example(b'x', b'', 1)
@example(b'x', b'', 2)
- at given(st.binary(), st.binary(), st.integers())
+ at given(st_bytestring, st_bytestring, st.integers())
def test_endswith_2(u, v, start):
expected = u[start:].endswith(v) if v else (start <= len(u))
assert u.endswith(v, start) is expected
@example(b'x', b'', 1, 0)
@example(b'xx', b'', -1, 0)
- at given(st.binary(), st.binary(), st.integers(), st.integers())
+ at given(st_bytestring, st_bytestring, st.integers(), st.integers())
def test_endswith_3(u, v, start, end):
if v:
expected = u[start:end].endswith(v)
More information about the pypy-commit
mailing list