(self)
| 283 | del e.errors |
| 284 | |
| 285 | def test_null_terminator(self): |
| 286 | # see gh-101828 |
| 287 | text = "フルーツ" |
| 288 | try: |
| 289 | text.encode(self.encoding) |
| 290 | except UnicodeEncodeError: |
| 291 | text = "Python is cool" |
| 292 | encode_w_null = (text + "\0").encode(self.encoding) |
| 293 | encode_plus_null = text.encode(self.encoding) + "\0".encode(self.encoding) |
| 294 | self.assertTrue(encode_w_null.endswith(b'\x00')) |
| 295 | self.assertEqual(encode_w_null, encode_plus_null) |
| 296 | |
| 297 | encode_w_null_2 = (text + "\0" + text + "\0").encode(self.encoding) |
| 298 | encode_plus_null_2 = encode_plus_null + encode_plus_null |
| 299 | self.assertEqual(encode_w_null_2.count(b'\x00'), 2) |
| 300 | self.assertEqual(encode_w_null_2, encode_plus_null_2) |
| 301 | |
| 302 | |
| 303 | class TestBase_Mapping(unittest.TestCase): |
nothing calls this directly
no test coverage detected