From 7424c69bde598a145b7d3807e6c367ac4b922bff Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Wed, 10 Oct 2018 05:48:54 -0700 Subject: Fix BytesWarning in tests Shouldn't try to coerce bytes to a string. Instead, print the repr value (e.g. b'mybytestring'). When running tests with the Python `-b` option, fixes warnings of the form: .../python-rsa/tests/test_strings.py:34: BytesWarning: str() on a bytes instance print("\tMessage: %s" % message) .../python-rsa/tests/test_strings.py:37: BytesWarning: str() on a bytes instance print("\tEncrypted: %s" % encrypted) .../python-rsa/tests/test_strings.py:40: BytesWarning: str() on a bytes instance print("\tDecrypted: %s" % decrypted) --- tests/test_strings.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/test_strings.py b/tests/test_strings.py index 28fa091..26404ae 100644 --- a/tests/test_strings.py +++ b/tests/test_strings.py @@ -31,12 +31,12 @@ class StringTest(unittest.TestCase): def test_enc_dec(self): message = unicode_string.encode('utf-8') - print("\tMessage: %s" % message) + print("\tMessage: %r" % message) encrypted = rsa.encrypt(message, self.pub) - print("\tEncrypted: %s" % encrypted) + print("\tEncrypted: %r" % encrypted) decrypted = rsa.decrypt(encrypted, self.priv) - print("\tDecrypted: %s" % decrypted) + print("\tDecrypted: %r" % decrypted) self.assertEqual(message, decrypted) -- cgit v1.2.1