Skip to content

Commit

Permalink
Fix BytesWarning in tests
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
jdufresne authored and sybrenstuvel committed Oct 23, 2018
1 parent 0eaeead commit 7424c69
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/test_strings.py
Expand Up @@ -31,12 +31,12 @@ def setUp(self):

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)

0 comments on commit 7424c69

Please sign in to comment.