diff options
author | Daniel Fortunov <asqui@users.noreply.github.com> | 2019-08-28 04:38:09 (GMT) |
---|---|---|
committer | Raymond Hettinger <rhettinger@users.noreply.github.com> | 2019-08-28 04:38:09 (GMT) |
commit | 2a16eea71f56c2d8f38c295c8ce71a9a9a140aff (patch) | |
tree | 71726a024fdfef5d79c432687fce143bbf2b41bd /Lib/test/test_userstring.py | |
parent | 98d90f745d35d5d07bffcb46788b50e05eea56c6 (diff) | |
download | cpython-2a16eea71f56c2d8f38c295c8ce71a9a9a140aff.zip cpython-2a16eea71f56c2d8f38c295c8ce71a9a9a140aff.tar.gz cpython-2a16eea71f56c2d8f38c295c8ce71a9a9a140aff.tar.bz2 |
bpo-36582: Make collections.UserString.encode() return bytes, not str (GH-13138)
Diffstat (limited to 'Lib/test/test_userstring.py')
-rw-r--r-- | Lib/test/test_userstring.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_userstring.py b/Lib/test/test_userstring.py index 19b0acf..4d1d8b6 100644 --- a/Lib/test/test_userstring.py +++ b/Lib/test/test_userstring.py @@ -51,6 +51,20 @@ class UserStringTest( str3 = ustr3('TEST') self.assertEqual(fmt2 % str3, 'value is TEST') + def test_encode_default_args(self): + self.checkequal(b'hello', 'hello', 'encode') + # Check that encoding defaults to utf-8 + self.checkequal(b'\xf0\xa3\x91\x96', '\U00023456', 'encode') + # Check that errors defaults to 'strict' + self.checkraises(UnicodeError, '\ud800', 'encode') + + def test_encode_explicit_none_args(self): + self.checkequal(b'hello', 'hello', 'encode', None, None) + # Check that encoding defaults to utf-8 + self.checkequal(b'\xf0\xa3\x91\x96', '\U00023456', 'encode', None, None) + # Check that errors defaults to 'strict' + self.checkraises(UnicodeError, '\ud800', 'encode', None, None) + if __name__ == "__main__": unittest.main() |