changeset: 90880:a981a088512c branch: 3.4 parent: 90876:6af865f1a59d user: Serhiy Storchaka date: Wed May 28 18:11:29 2014 +0300 files: Lib/test/test_ntpath.py Misc/NEWS description: Issue #21493: Added test for ntpath.expanduser(). Original patch by Claudiu Popa. diff -r 6af865f1a59d -r a981a088512c Lib/test/test_ntpath.py --- a/Lib/test/test_ntpath.py Wed May 28 12:58:34 2014 +0300 +++ b/Lib/test/test_ntpath.py Wed May 28 18:11:29 2014 +0300 @@ -258,6 +258,41 @@ 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 diff -r 6af865f1a59d -r a981a088512c Misc/NEWS --- a/Misc/NEWS Wed May 28 12:58:34 2014 +0300 +++ b/Misc/NEWS Wed May 28 18:11:29 2014 +0300 @@ -46,6 +46,9 @@ Tests ----- +- Issue #21493: Added test for ntpath.expanduser(). Original patch by + Claudiu Popa. + - Issue #19925: Added tests for the spwd module. Original patch by Vajrasky Kok. - Issue #21522: Added Tkinter tests for Listbox.itemconfigure(),