summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-05-28 15:11:29 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-05-28 15:11:29 (GMT)
commitffc1e6d42b3e8ffff7cdc6ff80dc9582c86a26c8 (patch)
tree3e25ccd4b62b2db64344b88d4890537de9a7af0e /Lib/test
parent47a981337a8f3898482a1c0c51ad2d91c7a6bc2f (diff)
downloadcpython-ffc1e6d42b3e8ffff7cdc6ff80dc9582c86a26c8.zip
cpython-ffc1e6d42b3e8ffff7cdc6ff80dc9582c86a26c8.tar.gz
cpython-ffc1e6d42b3e8ffff7cdc6ff80dc9582c86a26c8.tar.bz2
Issue #21493: Added test for ntpath.expanduser(). Original patch by
Claudiu Popa.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_ntpath.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py
index 000fc75..376f7ed 100644
--- a/Lib/test/test_ntpath.py
+++ b/Lib/test/test_ntpath.py
@@ -258,6 +258,41 @@ class TestNtpath(unittest.TestCase):
check('%spam%bar', '%sbar' % nonascii)
check('%{}%bar'.format(nonascii), 'ham%sbar' % nonascii)
+ def test_expanduser(self):
+ tester('ntpath.expanduser("test")', 'test')
+
+ with 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