diff options
| author | Serhiy Storchaka <storchaka@gmail.com> | 2014-05-28 15:11:08 (GMT) |
|---|---|---|
| committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-05-28 15:11:08 (GMT) |
| commit | 49b2086a2e1d43230bcb66dac38643b3736c24a6 (patch) | |
| tree | 8c35997f93b0aaccdb02dd649fe4624625cf220f /Lib/test/test_ntpath.py | |
| parent | 30080fd63d29e736e64d4d7b790f36485e0099b1 (diff) | |
| download | cpython-49b2086a2e1d43230bcb66dac38643b3736c24a6.zip cpython-49b2086a2e1d43230bcb66dac38643b3736c24a6.tar.gz cpython-49b2086a2e1d43230bcb66dac38643b3736c24a6.tar.bz2 | |
Issue #21493: Added test for ntpath.expanduser(). Original patch by
Claudiu Popa.
Diffstat (limited to 'Lib/test/test_ntpath.py')
| -rw-r--r-- | Lib/test/test_ntpath.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py index 1f1a971..6c16caf 100644 --- a/Lib/test/test_ntpath.py +++ b/Lib/test/test_ntpath.py @@ -213,6 +213,41 @@ class TestNtpath(unittest.TestCase): check('%spam%bar', '%sbar' % snonascii) check('%{}%bar'.format(snonascii), 'ham%sbar' % snonascii) + def test_expanduser(self): + tester('ntpath.expanduser("test")', 'test') + + with test_support.EnvironmentVarGuard() as env: + env.clear() + tester('ntpath.expanduser("~test")', '~test') + + env['HOMEPATH'] = 'eric\\idle' + env['HOMEDRIVE'] = 'C:\\' + tester('ntpath.expanduser("~test")', 'C:\\eric\\test') + tester('ntpath.expanduser("~")', 'C:\\eric\\idle') + + del env['HOMEDRIVE'] + tester('ntpath.expanduser("~test")', 'eric\\test') + tester('ntpath.expanduser("~")', 'eric\\idle') + + env.clear() + env['USERPROFILE'] = 'C:\\eric\\idle' + tester('ntpath.expanduser("~test")', 'C:\\eric\\test') + tester('ntpath.expanduser("~")', 'C:\\eric\\idle') + + env.clear() + env['HOME'] = 'C:\\idle\\eric' + tester('ntpath.expanduser("~test")', 'C:\\idle\\test') + tester('ntpath.expanduser("~")', 'C:\\idle\\eric') + + tester('ntpath.expanduser("~test\\foo\\bar")', + 'C:\\idle\\test\\foo\\bar') + tester('ntpath.expanduser("~test/foo/bar")', + 'C:\\idle\\test/foo/bar') + tester('ntpath.expanduser("~\\foo\\bar")', + 'C:\\idle\\eric\\foo\\bar') + tester('ntpath.expanduser("~/foo/bar")', + 'C:\\idle\\eric/foo/bar') + def test_abspath(self): # ntpath.abspath() can only be used on a system with the "nt" module # (reasonably), so we protect this test with "import nt". This allows |
