Test that Unicode strings outside the ASCII character set get escaped, using byte escapes if they're in that range or unicode escapes if they're not.
(self)
| 348 | escaped.encode("ascii") |
| 349 | |
| 350 | def test_unicode_idval(self) -> None: |
| 351 | """Test that Unicode strings outside the ASCII character set get |
| 352 | escaped, using byte escapes if they're in that range or unicode |
| 353 | escapes if they're not. |
| 354 | |
| 355 | """ |
| 356 | values = [ |
| 357 | ("", r""), |
| 358 | ("ascii", r"ascii"), |
| 359 | ("ação", r"a\xe7\xe3o"), |
| 360 | ("josé@blah.com", r"jos\xe9@blah.com"), |
| 361 | ( |
| 362 | r"δοκ.ιμή@παράδειγμα.δοκιμή", |
| 363 | r"\u03b4\u03bf\u03ba.\u03b9\u03bc\u03ae@\u03c0\u03b1\u03c1\u03ac\u03b4\u03b5\u03b9\u03b3" |
| 364 | r"\u03bc\u03b1.\u03b4\u03bf\u03ba\u03b9\u03bc\u03ae", |
| 365 | ), |
| 366 | ] |
| 367 | for val, expected in values: |
| 368 | assert ( |
| 369 | IdMaker([], [], None, None, None, None)._idval(val, "a", 6) == expected |
| 370 | ) |
| 371 | |
| 372 | def test_unicode_idval_with_config(self) -> None: |
| 373 | """Unit test for expected behavior to obtain ids with |