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

Method test_noinherit

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

Source from the content-addressed store, hash-verified

474 @unittest.skipUnless(has_spawnl, 'os.spawnl not available')
475 @support.requires_subprocess()
476 def test_noinherit(self):
477 # _mkstemp_inner file handles are not inherited by child processes
478
479 if support.verbose:
480 v="v"
481 else:
482 v="q"
483
484 file = self.do_create()
485 self.assertEqual(os.get_inheritable(file.fd), False)
486 fd = "%d" % file.fd
487
488 try:
489 me = __file__
490 except NameError:
491 me = sys.argv[0]
492
493 # We have to exec something, so that FD_CLOEXEC will take
494 # effect. The core of this test is therefore in
495 # tf_inherit_check.py, which see.
496 tester = os.path.join(os.path.dirname(os.path.abspath(me)),
497 "tf_inherit_check.py")
498
499 # On Windows a spawn* /path/ with embedded spaces shouldn't be quoted,
500 # but an arg with embedded spaces should be decorated with double
501 # quotes on each end
502 if sys.platform == 'win32':
503 decorated = '"%s"' % sys.executable
504 tester = '"%s"' % tester
505 else:
506 decorated = sys.executable
507
508 retval = os.spawnl(os.P_WAIT, sys.executable, decorated, tester, v, fd)
509 self.assertFalse(retval < 0,
510 "child process caught fatal signal %d" % -retval)
511 self.assertFalse(retval > 0, "child process reports failure %d"%retval)
512
513 @unittest.skipUnless(has_textmode, "text mode not available")
514 def test_textmode(self):

Callers

nothing calls this directly

Calls 7

do_createMethod · 0.95
assertFalseMethod · 0.80
assertEqualMethod · 0.45
get_inheritableMethod · 0.45
joinMethod · 0.45
dirnameMethod · 0.45
abspathMethod · 0.45

Tested by

no test coverage detected