diff -r 13b72f6365fe Lib/test/test_ntpath.py --- a/Lib/test/test_ntpath.py Mon May 26 01:00:34 2014 +1000 +++ b/Lib/test/test_ntpath.py Sun May 25 22:56:12 2014 +0300 @@ -341,6 +341,41 @@ self.assertTrue(ntpath.ismount(b"\\\\localhost\\c$")) self.assertTrue(ntpath.ismount(b"\\\\localhost\\c$\\")) + 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('~test\\foo\\bar')", + "C:\\eric\\test\\foo\\bar") + tester("ntpath.expanduser('~')", 'C:\\eric\\idle') + + del env['HOMEDRIVE'] + tester("ntpath.expanduser('~test')", 'eric\\test') + tester("ntpath.expanduser('~test\\foo\\bar')", + "eric\\test\\foo\\bar") + tester("ntpath.expanduser('~')", 'eric\\idle') + + env.clear() + env['USERPROFILE'] = 'C:\\eric\\idle' + tester("ntpath.expanduser('~test')", 'C:\\eric\\test') + tester("ntpath.expanduser('~test\\foo\\bar')", + "C:\\eric\\test\\foo\\bar") + tester("ntpath.expanduser('~')", 'C:\\eric\\idle') + + env.clear() + env['HOME'] = 'C:\\idle\\eric' + tester("ntpath.expanduser('~test')", 'C:\\idle\\test') + tester("ntpath.expanduser('~test\\foo\\bar')", + "C:\\idle\\test\\foo\\bar") + tester("ntpath.expanduser('~')", 'C:\\idle\\eric') + + class NtCommonTest(test_genericpath.CommonTest, unittest.TestCase): pathmodule = ntpath attributes = ['relpath', 'splitunc']