summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_ntpath.py
diff options
context:
space:
mode:
authorSjoerd Mullender <sjoerd@acm.org>2007-01-16 16:42:38 (GMT)
committerSjoerd Mullender <sjoerd@acm.org>2007-01-16 16:42:38 (GMT)
commit33a0a06d318a3d7164f6269c209b2309781af767 (patch)
tree88f61b958cde2b25523598a1ee9486ce6fd66074 /Lib/test/test_ntpath.py
parentfa3d08b4a92d8af3ec458137393b151a1a0b4391 (diff)
downloadcpython-33a0a06d318a3d7164f6269c209b2309781af767.zip
cpython-33a0a06d318a3d7164f6269c209b2309781af767.tar.gz
cpython-33a0a06d318a3d7164f6269c209b2309781af767.tar.bz2
Fixed ntpath.expandvars to not replace references to non-existing
variables with nothing. Also added tests. This fixes bug #494589.
Diffstat (limited to 'Lib/test/test_ntpath.py')
-rw-r--r--Lib/test/test_ntpath.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py
index 139aa1f..6bc2a05 100644
--- a/Lib/test/test_ntpath.py
+++ b/Lib/test/test_ntpath.py
@@ -115,6 +115,28 @@ tester("ntpath.normpath('K:../.././..')", r'K:..\..\..')
tester("ntpath.normpath('C:////a/b')", r'C:\a\b')
tester("ntpath.normpath('//machine/share//a/b')", r'\\machine\share\a\b')
+oldenv = os.environ.copy()
+try:
+ os.environ.clear()
+ os.environ["foo"] = "bar"
+ os.environ["{foo"] = "baz1"
+ os.environ["{foo}"] = "baz2"
+ tester('ntpath.expandvars("foo")', "foo")
+ tester('ntpath.expandvars("$foo bar")', "bar bar")
+ tester('ntpath.expandvars("${foo}bar")', "barbar")
+ tester('ntpath.expandvars("$[foo]bar")', "$[foo]bar")
+ tester('ntpath.expandvars("$bar bar")', "$bar bar")
+ tester('ntpath.expandvars("$?bar")', "$?bar")
+ tester('ntpath.expandvars("${foo}bar")', "barbar")
+ tester('ntpath.expandvars("$foo}bar")', "bar}bar")
+ tester('ntpath.expandvars("${foo")', "${foo")
+ tester('ntpath.expandvars("${{foo}}")', "baz1}")
+ tester('ntpath.expandvars("$foo$foo")', "barbar")
+ tester('ntpath.expandvars("$bar$bar")', "$bar$bar")
+finally:
+ os.environ.clear()
+ os.environ.update(oldenv)
+
# ntpath.abspath() can only be used on a system with the "nt" module
# (reasonably), so we protect this test with "import nt". This allows
# the rest of the tests for the ntpath module to be run to completion