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

Method test_umask

Lib/test/test_subprocess.py:2329–2347  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2327 @unittest.skipIf(mswindows or not hasattr(os, 'umask'),
2328 'POSIX umask() is not available.')
2329 def test_umask(self):
2330 tmpdir = None
2331 try:
2332 tmpdir = tempfile.mkdtemp()
2333 name = os.path.join(tmpdir, "beans")
2334 # We set an unusual umask in the child so as a unique mode
2335 # for us to test the child's touched file for.
2336 subprocess.check_call(
2337 [sys.executable, "-c", f"open({name!r}, 'w').close()"],
2338 umask=0o053)
2339 # Ignore execute permissions entirely in our test,
2340 # filesystems could be mounted to ignore or force that.
2341 st_mode = os.stat(name).st_mode & 0o666
2342 expected_mode = 0o624
2343 self.assertEqual(expected_mode, st_mode,
2344 msg=f'{oct(expected_mode)} != {oct(st_mode)}')
2345 finally:
2346 if tmpdir is not None:
2347 shutil.rmtree(tmpdir)
2348
2349 def test_run_abort(self):
2350 # returncode handles signal termination

Callers

nothing calls this directly

Calls 5

octFunction · 0.85
mkdtempMethod · 0.80
joinMethod · 0.45
statMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected