|
| 1 | +import inspect |
1 | 2 | import ntpath
|
2 | 3 | import os
|
3 | 4 | import sys
|
4 | 5 | import unittest
|
5 | 6 | import warnings
|
6 |
| -from test.support import os_helper |
| 7 | +from test.support import cpython_only, os_helper |
7 | 8 | from test.support import TestFailed, is_emscripten
|
8 | 9 | from test.support.os_helper import FakePath
|
9 | 10 | from test import test_genericpath
|
@@ -938,6 +939,35 @@ def test_isjunction(self):
|
938 | 939 | self.assertFalse(ntpath.isjunction('tmpdir'))
|
939 | 940 | self.assertPathEqual(ntpath.realpath('testjunc'), ntpath.realpath('tmpdir'))
|
940 | 941 |
|
| 942 | + @unittest.skipIf(sys.platform != 'win32', "drive letters are a windows concept") |
| 943 | + def test_isfile_driveletter(self): |
| 944 | + drive = os.environ.get('SystemDrive') |
| 945 | + if drive is None or len(drive) != 2 or drive[1] != ':': |
| 946 | + raise unittest.SkipTest('SystemDrive is not defined or malformed') |
| 947 | + self.assertFalse(os.path.isfile('\\\\.\\' + drive)) |
| 948 | + |
| 949 | + @unittest.skipIf(sys.platform != 'win32', "windows only") |
| 950 | + def test_con_device(self): |
| 951 | + self.assertFalse(os.path.isfile(r"\\.\CON")) |
| 952 | + self.assertFalse(os.path.isdir(r"\\.\CON")) |
| 953 | + self.assertFalse(os.path.islink(r"\\.\CON")) |
| 954 | + self.assertTrue(os.path.exists(r"\\.\CON")) |
| 955 | + |
| 956 | + @unittest.skipIf(sys.platform != 'win32', "Fast paths are only for win32") |
| 957 | + @cpython_only |
| 958 | + def test_fast_paths_in_use(self): |
| 959 | + # There are fast paths of these functions implemented in posixmodule.c. |
| 960 | + # Confirm that they are being used, and not the Python fallbacks in |
| 961 | + # genericpath.py. |
| 962 | + self.assertTrue(os.path.isdir is nt._path_isdir) |
| 963 | + self.assertFalse(inspect.isfunction(os.path.isdir)) |
| 964 | + self.assertTrue(os.path.isfile is nt._path_isfile) |
| 965 | + self.assertFalse(inspect.isfunction(os.path.isfile)) |
| 966 | + self.assertTrue(os.path.islink is nt._path_islink) |
| 967 | + self.assertFalse(inspect.isfunction(os.path.islink)) |
| 968 | + self.assertTrue(os.path.exists is nt._path_exists) |
| 969 | + self.assertFalse(inspect.isfunction(os.path.exists)) |
| 970 | + |
941 | 971 |
|
942 | 972 | class NtCommonTest(test_genericpath.CommonTest, unittest.TestCase):
|
943 | 973 | pathmodule = ntpath
|
|
0 commit comments