def test_nt_helpers(self): # Trivial validation that the helpers do not break, and support both # unicode and bytes (UTF-8) paths drive, path = ntpath.splitdrive(sys.executable) drive = drive.rstrip(ntpath.sep) + ntpath.sep self.assertEqual(drive, nt._getvolumepathname(sys.executable)) self.assertEqual(drive.encode(), nt._getvolumepathname(sys.executable.encode())) cap, free = nt._getdiskusage(sys.exec_prefix) self.assertGreater(cap, 0) self.assertGreater(free, 0) b_cap, b_free = nt._getdiskusage(sys.exec_prefix.encode()) # Free space may change, so only test the capacity is equal self.assertEqual(b_cap, cap) self.assertGreater(b_free, 0) for path in [sys.prefix, sys.executable]: final_path = nt._getfinalpathname(path) self.assertIsInstance(final_path, str) self.assertGreater(len(final_path), 0) b_final_path = nt._getfinalpathname(path.encode()) self.assertIsInstance(b_final_path, bytes) self.assertGreater(len(b_final_path), 0)
def test_nt_helpers(self): # Trivial validation that the helpers do not break, and support both # unicode and bytes (UTF-8) paths drive, path = ntpath.splitdrive(sys.executable) drive = drive.rstrip(ntpath.sep) + ntpath.sep self.assertEqual(drive, nt._getvolumepathname(sys.executable)) self.assertEqual(drive.encode(), nt._getvolumepathname(sys.executable.encode())) cap, free = nt._getdiskusage(sys.exec_prefix) self.assertGreater(cap, 0) self.assertGreater(free, 0) b_cap, b_free = nt._getdiskusage(sys.exec_prefix.encode()) # Free space may change, so only test the capacity is equal self.assertEqual(b_cap, cap) self.assertGreater(b_free, 0) for path in [sys.prefix, sys.executable]: final_path = nt._getfinalpathname(path) self.assertIsInstance(final_path, str) self.assertGreater(len(final_path), 0) b_final_path = nt._getfinalpathname(path.encode()) self.assertIsInstance(b_final_path, bytes) self.assertGreater(len(b_final_path), 0)
def ismount(path): """Test whether a path is a mount point (a drive root, the root of a share, or a mounted volume)""" seps = _get_bothseps(path) path = abspath(path) root, rest = splitdrive(path) if root and root[0] in seps: return (not rest) or (rest in seps) if rest in seps: return True if _getvolumepathname: return path.rstrip(seps) == _getvolumepathname(path).rstrip(seps) else: return False
def ismount(path): """Test whether a path is a mount point (a drive root, the root of a share, or a mounted volume)""" seps = _get_bothseps(path) path = abspath(path) root, rest = splitdrive(path) if root and root[0] in seps: return (not rest) or (rest in seps) if rest in seps: return True if _getvolumepathname: return path.rstrip(seps) == _getvolumepathname(path).rstrip(seps) else: return False