MCPcopy Index your code
hub / github.com/python/cpython / test_misformed_unicode_character_name

Method test_misformed_unicode_character_name

Lib/test/test_fstring.py:1005–1022  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1003 self.assertEqual(f'\\\N{AMPERSAND}', '\\&')
1004
1005 def test_misformed_unicode_character_name(self):
1006 # These test are needed because unicode names are parsed
1007 # differently inside f-strings.
1008 self.assertAllRaise(SyntaxError, r"\(unicode error\) 'unicodeescape' codec can't decode bytes in position .*: malformed \\N character escape",
1009 [r"f'\N'",
1010 r"f'\N '",
1011 r"f'\N '", # See bpo-46503.
1012 r"f'\N{'",
1013 r"f'\N{GREEK CAPITAL LETTER DELTA'",
1014
1015 # Here are the non-f-string versions,
1016 # which should give the same errors.
1017 r"'\N'",
1018 r"'\N '",
1019 r"'\N '",
1020 r"'\N{'",
1021 r"'\N{GREEK CAPITAL LETTER DELTA'",
1022 ])
1023
1024 def test_backslashes_in_expression_part(self):
1025 self.assertEqual(f"{(

Callers

nothing calls this directly

Calls 1

assertAllRaiseMethod · 0.95

Tested by

no test coverage detected