Hypothesis-based roundtrip test.

This commit is contained in:
Itamar Turner-Trauring 2020-07-13 16:19:48 -04:00
parent 828e6bc28a
commit 6464e226c6

View File

@ -1,5 +1,10 @@
import random, unittest
from hypothesis import (
strategies as st,
given,
)
from allmydata.util import base62, mathutil
def insecurerandstr(n):
@ -14,6 +19,10 @@ class T(unittest.TestCase):
bs2=base62.a2b(ascii)
assert bs2 == bs, "bs2: %s:%s, bs: %s:%s, ascii: %s:%s" % (len(bs2), repr(bs2), len(bs), repr(bs), len(ascii), repr(ascii))
@given(input_bytes=st.binary(max_size=100))
def test_roundtrip(self, input_bytes):
self._test_ende(input_bytes)
def test_num_octets_that_encode_to_this_many_chars(self):
return self._test_num_octets_that_encode_to_this_many_chars(2, 1)
return self._test_num_octets_that_encode_to_this_many_chars(3, 2)