]> granicus.if.org Git - python/commitdiff
Only test ntpath.abspath() on Windows. This allows the rest of the module to
authorFred Drake <fdrake@acm.org>
Tue, 15 Jan 2002 03:46:43 +0000 (03:46 +0000)
committerFred Drake <fdrake@acm.org>
Tue, 15 Jan 2002 03:46:43 +0000 (03:46 +0000)
be tested regardless of the host platform.

Lib/test/test_ntpath.py

index 336e9e2e7a0d29c197272a8e820fa1f6fb0dfc0e..4dee1fc00ccbd3fb9e7ac65d8108aa39a2a2384f 100644 (file)
@@ -41,8 +41,6 @@ tester('ntpath.isabs("\\\\conky\\mountpoint\\")', 1)
 tester('ntpath.isabs("\\foo")', 1)
 tester('ntpath.isabs("\\foo\\bar")', 1)
 
-tester('ntpath.abspath("C:\\")', "C:\\")
-
 tester('ntpath.commonprefix(["/home/swenson/spam", "/home/swen/spam"])',
        "/home/swen")
 tester('ntpath.commonprefix(["\\home\\swen\\spam", "\\home\\swen\\eggs"])',
@@ -108,6 +106,18 @@ tester("ntpath.normpath('c:/../../..')", 'c:\\')
 tester("ntpath.normpath('../.././..')", r'..\..\..')
 tester("ntpath.normpath('K:../.././..')", r'K:..\..\..')
 
+# 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
+# on any platform, since most of the module is intended to be usable
+# from any platform.
+try:
+    import nt
+except ImportError:
+    pass
+else:
+    tester('ntpath.abspath("C:\\")', "C:\\")
+
 if errors:
     raise TestFailed(str(errors) + " errors.")
 elif verbose: