diff options
| author | Serhiy Storchaka <storchaka@gmail.com> | 2015-02-13 10:02:05 (GMT) |
|---|---|---|
| committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-02-13 10:02:05 (GMT) |
| commit | 2bd8b22b6de76851a7e36dc4a92d20930335ff57 (patch) | |
| tree | 648a3e23f9a7d001b061930d3d07ef772de5477f /Lib/test/test_posixpath.py | |
| parent | 4068b01cb55a66efca605d64b6e27d9fd7cebd3e (diff) | |
| download | cpython-2bd8b22b6de76851a7e36dc4a92d20930335ff57.zip cpython-2bd8b22b6de76851a7e36dc4a92d20930335ff57.tar.gz cpython-2bd8b22b6de76851a7e36dc4a92d20930335ff57.tar.bz2 | |
Issue #21840: Fixed expanding unicode variables of form $var in
posixpath.expandvars(). Fixed all os.path implementations on
unicode-disabled builds.
Diffstat (limited to 'Lib/test/test_posixpath.py')
| -rw-r--r-- | Lib/test/test_posixpath.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py index f74dc14..295bf49 100644 --- a/Lib/test/test_posixpath.py +++ b/Lib/test/test_posixpath.py @@ -1,7 +1,9 @@ import unittest from test import test_support, test_genericpath -import posixpath, os +import posixpath +import os +import sys from posixpath import realpath, abspath, dirname, basename # An absolute path to a temporary filename for testing. We can't rely on TESTFN @@ -409,6 +411,21 @@ class PosixPathTest(unittest.TestCase): finally: os.getcwd = real_getcwd + @test_support.requires_unicode + def test_expandvars_nonascii_word(self): + encoding = sys.getfilesystemencoding() + # Non-ASCII word characters + letters = test_support.u(r'\xe6\u0130\u0141\u03c6\u041a\u05d0\u062a\u0e01') + uwnonascii = letters.encode(encoding, 'ignore').decode(encoding)[:3] + swnonascii = uwnonascii.encode(encoding) + if not swnonascii: + self.skip('Needs non-ASCII word characters') + with test_support.EnvironmentVarGuard() as env: + env.clear() + env[swnonascii] = 'baz' + swnonascii + self.assertEqual(posixpath.expandvars(u'$%s bar' % uwnonascii), + u'baz%s bar' % uwnonascii) + class PosixCommonTest(test_genericpath.CommonTest): pathmodule = posixpath |
