Skip to content

Commit 956817c

Browse files
committed
Add a test exposing newbytes constructor bug (issue #193)
1 parent 55e8227 commit 956817c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/test_future/test_bytes.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ def test_bytes_encoding_arg(self):
2929
b = bytes(u, encoding='utf-8')
3030
self.assertEqual(b, u.encode('utf-8'))
3131

32+
def test_bytes_encoding_arg_issue_193(self):
33+
"""
34+
This used to be True: bytes(str(u'abc'), 'utf8') == b"b'abc'"
35+
"""
36+
u = u'abc'
37+
b = bytes(str(u), 'utf8')
38+
self.assertNotEqual(b, b"b'abc'")
39+
self.assertEqual(b, b'abc')
40+
self.assertEqual(b, bytes(b'abc'))
41+
3242
def test_bytes_encoding_arg_non_kwarg(self):
3343
"""
3444
As above, but with a positional argument

0 commit comments

Comments
 (0)