MCPcopy Index your code
hub / github.com/python/cpython / test_mode_win32

Method test_mode_win32

Lib/test/test_tempfile.py:817–841  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

815
816 @unittest.skipUnless(os.name == "nt", "Only on Windows.")
817 def test_mode_win32(self):
818 # Use icacls.exe to extract the users with some level of access
819 # Main thing we are testing is that the BUILTIN\Users group has
820 # no access. The exact ACL is going to vary based on which user
821 # is running the test.
822 dir = self.do_create()
823 try:
824 out = subprocess.check_output(["icacls.exe", dir], encoding="oem").casefold()
825 finally:
826 os.rmdir(dir)
827
828 dir = dir.casefold()
829 users = set()
830 found_user = False
831 for line in out.strip().splitlines():
832 acl = None
833 # First line of result includes our directory
834 if line.startswith(dir):
835 acl = line.removeprefix(dir).strip()
836 elif line and line[:1].isspace():
837 acl = line.strip()
838 if acl:
839 users.add(acl.partition(":")[0])
840
841 self.assertNotIn(r"BUILTIN\Users".casefold(), users)
842
843 def test_collision_with_existing_file(self):
844 # mkdtemp tries another name when a file with

Callers

nothing calls this directly

Calls 13

do_createMethod · 0.95
setFunction · 0.85
casefoldMethod · 0.80
rmdirMethod · 0.80
isspaceMethod · 0.80
assertNotInMethod · 0.80
check_outputMethod · 0.45
splitlinesMethod · 0.45
stripMethod · 0.45
startswithMethod · 0.45
removeprefixMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected