diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-10-03 09:08:38 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-10-03 09:08:38 (GMT) |
commit | def0a4c298358c50b0b53a8113551e9aee3532e5 (patch) | |
tree | 7fc497bed47259280aa94fc9d6fcd34388a93882 /Lib/lib2to3/tests | |
parent | 2a8b3f26b91d6f1774c73fe4f545d2eb94475525 (diff) | |
download | cpython-def0a4c298358c50b0b53a8113551e9aee3532e5.zip cpython-def0a4c298358c50b0b53a8113551e9aee3532e5.tar.gz cpython-def0a4c298358c50b0b53a8113551e9aee3532e5.tar.bz2 |
Issue #18037: 2to3 now escapes '\u' and '\U' in native strings.
Diffstat (limited to 'Lib/lib2to3/tests')
-rw-r--r-- | Lib/lib2to3/tests/test_fixers.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/Lib/lib2to3/tests/test_fixers.py b/Lib/lib2to3/tests/test_fixers.py index 2d20b08..bffb741 100644 --- a/Lib/lib2to3/tests/test_fixers.py +++ b/Lib/lib2to3/tests/test_fixers.py @@ -2824,6 +2824,43 @@ class Test_unicode(FixerTestCase): a = """R'''x''' """ self.check(b, a) + def test_native_literal_escape_u(self): + b = r"""'\\\u20ac\U0001d121\\u20ac'""" + a = r"""'\\\\u20ac\\U0001d121\\u20ac'""" + self.check(b, a) + + b = r"""r'\\\u20ac\U0001d121\\u20ac'""" + a = r"""r'\\\\u20ac\\U0001d121\\u20ac'""" + self.check(b, a) + + def test_bytes_literal_escape_u(self): + b = r"""b'\\\u20ac\U0001d121\\u20ac'""" + a = r"""b'\\\u20ac\U0001d121\\u20ac'""" + self.check(b, a) + + b = r"""br'\\\u20ac\U0001d121\\u20ac'""" + a = r"""br'\\\u20ac\U0001d121\\u20ac'""" + self.check(b, a) + + def test_unicode_literal_escape_u(self): + b = r"""u'\\\u20ac\U0001d121\\u20ac'""" + a = r"""'\\\u20ac\U0001d121\\u20ac'""" + self.check(b, a) + + b = r"""ur'\\\u20ac\U0001d121\\u20ac'""" + a = r"""r'\\\u20ac\U0001d121\\u20ac'""" + self.check(b, a) + + def test_native_unicode_literal_escape_u(self): + f = 'from __future__ import unicode_literals\n' + b = f + r"""'\\\u20ac\U0001d121\\u20ac'""" + a = f + r"""'\\\u20ac\U0001d121\\u20ac'""" + self.check(b, a) + + b = f + r"""r'\\\u20ac\U0001d121\\u20ac'""" + a = f + r"""r'\\\u20ac\U0001d121\\u20ac'""" + self.check(b, a) + class Test_callable(FixerTestCase): fixer = "callable" |