gh-94808: Coverage: Test uppercase string literal prefixes (GH-95925)

(cherry picked from commit f00383ec9b)

Co-authored-by: Michael Droettboom <mdboom@gmail.com>
This commit is contained in:
Miss Islington (bot) 2022-09-25 01:58:50 -07:00 committed by GitHub
parent f29c88de52
commit 00713a8b3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -213,6 +213,13 @@ def test_eval_str_u(self):
self.assertRaises(SyntaxError, eval, """ bu'' """)
self.assertRaises(SyntaxError, eval, """ ub'' """)
def test_uppercase_prefixes(self):
self.assertEqual(eval(""" B'x' """), b'x')
self.assertEqual(eval(r""" R'\x01' """), r'\x01')
self.assertEqual(eval(r""" BR'\x01' """), br'\x01')
self.assertEqual(eval(""" F'{1+1}' """), f'{1+1}')
self.assertEqual(eval(r""" U'\U0001d120' """), u'\U0001d120')
def check_encoding(self, encoding, extra=""):
modname = "xx_" + encoding.replace("-", "_")
fn = os.path.join(self.tmpdir, modname + ".py")