From 9fccf3705336083da6bb8f181825232b9ba0add4 Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Wed, 23 Sep 2020 08:24:39 -0400 Subject: [PATCH] Make new code more idiomatic --- src/allmydata/test/common_util.py | 2 +- src/allmydata/test/test_common_util.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/allmydata/test/common_util.py b/src/allmydata/test/common_util.py index cea37c673..83164aa3c 100644 --- a/src/allmydata/test/common_util.py +++ b/src/allmydata/test/common_util.py @@ -73,7 +73,7 @@ def flip_bit(good, which): def flip_one_bit(s, offset=0, size=None): """ flip one random bit of the string s, in a byte greater than or equal to offset and less than offset+size. """ - assert isinstance(s, binary_type) + precondition(isinstance(s, binary_type)) if size is None: size=len(s)-offset i = randrange(offset, offset+size) diff --git a/src/allmydata/test/test_common_util.py b/src/allmydata/test/test_common_util.py index 76ff57705..0e2f49f34 100644 --- a/src/allmydata/test/test_common_util.py +++ b/src/allmydata/test/test_common_util.py @@ -22,9 +22,9 @@ class TestFlipOneBit(unittest.TestCase): def setUp(self): random.seed(42) # I tried using version=1 on PY3 to avoid the if below, to no avail. - def test_bytestring(self): + def test_accepts_byte_string(self): actual = flip_one_bit(b'foo') self.assertEqual(actual, b'fno' if PY2 else b'fom') - def test_unicode(self): + def test_rejects_unicode_string(self): self.assertRaises(AssertionError, flip_one_bit, u'foo')