Skip to content

Commit

Permalink
Merge pull request benoitc#1664 from hramezani/test_to_bytestring_util
Browse files Browse the repository at this point in the history
Add some tests for `to_bytestring` util
  • Loading branch information
tilgovi committed Dec 11, 2017
2 parents 123b33e + 360f71e commit d7cc56e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/test_util.py
Expand Up @@ -59,3 +59,13 @@ def test_import_app():
util.import_app('support:wrong_app')
msg = "Failed to find application object 'wrong_app' in 'support'"
assert msg in str(err)


def test_to_bytestring():
assert util.to_bytestring('test_str', 'ascii') == b'test_str'
assert util.to_bytestring('test_str®') == b'test_str\xc2\xae'
assert util.to_bytestring(b'byte_test_str') == b'byte_test_str'
with pytest.raises(TypeError) as err:
util.to_bytestring(100)
msg = '100 is not a string'
assert msg in str(err)

0 comments on commit d7cc56e

Please sign in to comment.