MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_mode_win32

Method test_mode_win32

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

Source from the content-addressed store, hash-verified

796
797 @unittest.skipUnless(os.name == "nt", "Only on Windows.")
798 def test_mode_win32(self):
799 # Use icacls.exe to extract the users with some level of access
800 # Main thing we are testing is that the BUILTIN\Users group has
801 # no access. The exact ACL is going to vary based on which user
802 # is running the test.
803 dir = self.do_create()
804 try:
805 out = subprocess.check_output(["icacls.exe", dir], encoding="oem").casefold()
806 finally:
807 os.rmdir(dir)
808
809 dir = dir.casefold()
810 users = set()
811 found_user = False
812 for line in out.strip().splitlines():
813 acl = None
814 # First line of result includes our directory
815 if line.startswith(dir):
816 acl = line.removeprefix(dir).strip()
817 elif line and line[:1].isspace():
818 acl = line.strip()
819 if acl:
820 users.add(acl.partition(":")[0])
821
822 self.assertNotIn(r"BUILTIN\Users".casefold(), users)
823
824 def test_collision_with_existing_file(self):
825 # mkdtemp tries another name when a file with

Callers

nothing calls this directly

Calls 13

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

Tested by

no test coverage detected