本文整理汇总了Python中test.support.reap_children函数的典型用法代码示例。如果您正苦于以下问题:Python reap_children函数的具体用法?Python reap_children怎么用?Python reap_children使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了reap_children函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_main
def test_main():
try:
test.support.run_unittest(
PydocDocTest, PydocImportTest, TestDescriptions, PydocServerTest, PydocUrlHandlerTest, TestHelper
)
finally:
reap_children()
示例2: test_main
def test_main():
try:
support.run_unittest(BasicSignalTests, InterProcessSignalTests,
WakeupSignalTests, SiginterruptTest,
ItimerTest, WindowsSignalTests)
finally:
support.reap_children()
示例3: test_main
def test_main():
support.run_unittest(
BZ2FileTest,
BZ2CompressorTest,
BZ2DecompressorTest,
FuncTest
)
support.reap_children()
示例4: test_main
def test_main():
try:
support.run_unittest(PosixTests, InterProcessSignalTests,
WakeupFDTests, WakeupSignalTests,
SiginterruptTest, ItimerTest, WindowsSignalTests,
PendingSignalsTests)
finally:
support.reap_children()
示例5: test_main
def test_main():
support.run_unittest(
BZ2FileTest,
BZ2CompressorTest,
BZ2DecompressorTest,
CompressDecompressTest,
OpenTest,
)
support.reap_children()
示例6: tearDown
def tearDown(self):
signal_alarm(0) # Didn't deadlock.
reap_children()
for fn in self.test_files:
try:
os.remove(fn)
except os.error:
pass
self.test_files[:] = []
示例7: test_main
def test_main():
try:
start_dir = os.path.dirname(__file__)
top_dir = os.path.dirname(os.path.dirname(start_dir))
test_loader = unittest.TestLoader()
# XXX find out how to use unittest.main, to get command-line options
# (failfast, catch, etc.)
run_unittest(test_loader.discover(start_dir, top_level_dir=top_dir))
finally:
reap_children()
示例8: run_pydoc
def run_pydoc(module_name, *args):
"""
Runs pydoc on the specified module. Returns the stripped
output of pydoc.
"""
cmd = [sys.executable, pydoc.__file__, " ".join(args), module_name]
try:
output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]
return output.strip()
finally:
reap_children()
示例9: test_main
def test_main():
unit_tests = (ProcessTestCase,
POSIXProcessTestCase,
Win32ProcessTestCase,
ProcessTestCasePOSIXPurePython,
CommandTests,
ProcessTestCaseNoPoll,
HelperFunctionTests,
CommandsWithSpaces)
support.run_unittest(*unit_tests)
support.reap_children()
示例10: tearDown
def tearDown(self):
for inst in popen2._active:
inst.wait()
popen2._cleanup()
self.assertFalse(popen2._active, "popen2._active not empty")
# The os.popen*() API delegates to the subprocess module (on Unix)
import subprocess
for inst in subprocess._active:
inst.wait()
subprocess._cleanup()
self.assertFalse(subprocess._active, "subprocess._active not empty")
reap_children()
示例11: tearDown
def tearDown(self):
self.unpatch_get_running_loop()
events.set_event_loop(None)
# Detect CPython bug #23353: ensure that yield/yield-from is not used
# in an except block of a generator
self.assertEqual(sys.exc_info(), (None, None, None))
self.doCleanups()
support.threading_cleanup(*self._thread_cleanup)
support.reap_children()
示例12: test_main
def test_main():
try:
test.support.run_unittest(PydocDocTest,
PydocImportTest,
TestDescriptions,
PydocServerTest,
PydocUrlHandlerTest,
TestHelper,
PydocWithMetaClasses,
TestInternalUtilities,
)
finally:
reap_children()
示例13: test_popen
def test_popen(self):
self.assertRaises(TypeError, os.popen)
self._do_test_commandline(
"foo bar",
["foo", "bar"]
)
self._do_test_commandline(
'foo "spam and eggs" "silly walk"',
["foo", "spam and eggs", "silly walk"]
)
self._do_test_commandline(
'foo "a \\"quoted\\" arg" bar',
["foo", 'a "quoted" arg', "bar"]
)
support.reap_children()
示例14: test_reap_children
def test_reap_children(self):
# Make sure that there is no other pending child process
support.reap_children()
# Create a child process
pid = os.fork()
if pid == 0:
# child process: do nothing, just exit
os._exit(0)
t0 = time.monotonic()
deadline = time.monotonic() + 60.0
was_altered = support.environment_altered
try:
support.environment_altered = False
stderr = io.StringIO()
while True:
if time.monotonic() > deadline:
self.fail("timeout")
with contextlib.redirect_stderr(stderr):
support.reap_children()
# Use environment_altered to check if reap_children() found
# the child process
if support.environment_altered:
break
# loop until the child process completed
time.sleep(0.100)
msg = "Warning -- reap_children() reaped child process %s" % pid
self.assertIn(msg, stderr.getvalue())
self.assertTrue(support.environment_altered)
finally:
support.environment_altered = was_altered
# Just in case, check again that there is no other
# pending child process
support.reap_children()
示例15: test_main
def test_main():
support.run_unittest(ProcessTestCase, CommandTests)
support.reap_children()