summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Droettboom <mdboom@gmail.com>2022-09-24 10:43:16 (GMT)
committerGitHub <noreply@github.com>2022-09-24 10:43:16 (GMT)
commitf00383ec9bb9452fd9d5f5003f123e68fc4a71d8 (patch)
tree088beaa9a0cd873d7554700d39d34a64231dbd5b
parenta4ac14faa5c2be433738dfbbed14b0eaa1a2399e (diff)
downloadcpython-f00383ec9bb9452fd9d5f5003f123e68fc4a71d8.zip
cpython-f00383ec9bb9452fd9d5f5003f123e68fc4a71d8.tar.gz
cpython-f00383ec9bb9452fd9d5f5003f123e68fc4a71d8.tar.bz2
gh-94808: Coverage: Test uppercase string literal prefixes (GH-95925)
-rw-r--r--Lib/test/test_string_literals.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_string_literals.py b/Lib/test/test_string_literals.py
index 3a3830b..7247b7e 100644
--- a/Lib/test/test_string_literals.py
+++ b/Lib/test/test_string_literals.py
@@ -266,6 +266,13 @@ class TestLiterals(unittest.TestCase):
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")