Esempio n. 1
0
def test_main():
    try:
        test.support.run_unittest(
            PydocDocTest, PydocImportTest, TestDescriptions, PydocServerTest, PydocUrlHandlerTest, TestHelper
        )
    finally:
        reap_children()
Esempio n. 2
0
def test_main():
    try:
        support.run_unittest(BasicSignalTests, InterProcessSignalTests,
                             WakeupSignalTests, SiginterruptTest,
                             ItimerTest, WindowsSignalTests)
    finally:
        support.reap_children()
def test_main():
    support.run_unittest(
        BZ2FileTest,
        BZ2CompressorTest,
        BZ2DecompressorTest,
        FuncTest
    )
    support.reap_children()
Esempio n. 4
0
def test_main():
    try:
        support.run_unittest(PosixTests, InterProcessSignalTests,
                             WakeupFDTests, WakeupSignalTests,
                             SiginterruptTest, ItimerTest, WindowsSignalTests,
                             PendingSignalsTests)
    finally:
        support.reap_children()
Esempio n. 5
0
def test_main():
    support.run_unittest(
        BZ2FileTest,
        BZ2CompressorTest,
        BZ2DecompressorTest,
        CompressDecompressTest,
        OpenTest,
    )
    support.reap_children()
Esempio n. 6
0
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()
Esempio n. 7
0
    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[:] = []
Esempio n. 8
0
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()
Esempio n. 9
0
def _runtest_inner2(ns, test_name):
    # Load the test function, run the test function, handle huntrleaks
    # and findleaks to detect leaks

    abstest = get_abs_module(ns, test_name)

    # remove the module from sys.module to reload it if it was already imported
    support.unload(abstest)

    try:
        the_module = importlib.import_module(abstest)

        # If the test has a test_main, that will run the appropriate
        # tests.  If not, use normal unittest test loading.
        test_runner = getattr(the_module, "test_main", None)
        if test_runner is None:
            test_runner = functools.partial(_test_module, the_module)
    except ModuleNotFoundError:

        def test_runner():
            loader = unittest.TestLoader()
            tests = loader.loadTestsFromName(abstest)
            for error in loader.errors:
                print(error, file=sys.stderr)
            if loader.errors:
                raise Exception("errors while loading tests")
            support.run_unittest(tests)

    try:
        if ns.huntrleaks:
            # Return True if the test leaked references
            refleak = dash_R(ns, test_name, test_runner)
        else:
            test_runner()
            refleak = False
    finally:
        cleanup_test_droppings(test_name, ns.verbose)

    support.gc_collect()

    if gc.garbage:
        support.environment_altered = True
        print_warning(f"{test_name} created {len(gc.garbage)} "
                      f"uncollectable object(s).")

        # move the uncollectable objects somewhere,
        # so we don't see them again
        FOUND_GARBAGE.extend(gc.garbage)
        gc.garbage.clear()

    support.reap_children()

    return refleak
Esempio n. 10
0
 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()
Esempio n. 11
0
def test_main():
    try:
        test.support.run_unittest(PydocDocTest,
                                  PydocImportTest,
                                  TestDescriptions,
                                  PydocServerTest,
                                  PydocUrlHandlerTest,
                                  TestHelper,
                                  PydocWithMetaClasses,
                                  )
    finally:
        reap_children()
Esempio n. 12
0
def _runtest_inner2(ns: Namespace, test_name: str) -> bool:
    # Load the test function, run the test function, handle huntrleaks
    # to detect leaks.

    abstest = get_abs_module(ns, test_name)

    # remove the module from sys.module to reload it if it was already imported
    try:
        del sys.modules[abstest]
    except KeyError:
        pass

    the_module = importlib.import_module(abstest)

    if ns.huntrleaks:
        from test.libregrtest.refleak import dash_R

    # If the test has a test_main, that will run the appropriate
    # tests.  If not, use normal unittest test loading.
    test_runner = getattr(the_module, "test_main", None)
    if test_runner is None:
        test_runner = functools.partial(_test_module, the_module)

    try:
        with save_env(ns, test_name):
            if ns.huntrleaks:
                # Return True if the test leaked references
                refleak = dash_R(ns, test_name, test_runner)
            else:
                test_runner()
                refleak = False
    finally:
        # First kill any dangling references to open files etc.
        # This can also issue some ResourceWarnings which would otherwise get
        # triggered during the following test run, and possibly produce
        # failures.
        support.gc_collect()

        cleanup_test_droppings(test_name, ns.verbose)

    if gc.garbage:
        support.environment_altered = True
        print_warning(f"{test_name} created {len(gc.garbage)} "
                      f"uncollectable object(s).")

        # move the uncollectable objects somewhere,
        # so we don't see them again
        FOUND_GARBAGE.extend(gc.garbage)
        gc.garbage.clear()

    support.reap_children()

    return refleak
def test_main():
    unit_tests = (ProcessTestCase,
                  POSIXProcessTestCase,
                  Win32ProcessTestCase,
                  ProcessTestCasePOSIXPurePython,
                  CommandTests,
                  ProcessTestCaseNoPoll,
                  HelperFunctionTests,
                  CommandsWithSpaces)

    support.run_unittest(*unit_tests)
    support.reap_children()
Esempio n. 14
0
    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()
Esempio n. 15
0
    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()
Esempio n. 16
0
 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"])
     if sys.platform == 'OpenVMS':
         # in DCL quote is passed as double quote
         self._do_test_commandline('foo "a \"\"quoted\"\" arg" bar',
                                   ["foo", 'a "quoted" arg', "bar"])
     else:
         self._do_test_commandline('foo "a \\"quoted\\" arg" bar',
                                   ["foo", 'a "quoted" arg', "bar"])
     support.reap_children()
Esempio n. 17
0
def tearDownModule():
    support.threading_cleanup(*_threads_key)
    support.reap_children()

    # cleanup multiprocessing
    multiprocessing.process._cleanup()
    # Stop the ForkServer process if it's running
    from multiprocessing import forkserver
    forkserver._forkserver._stop()
    # bpo-37421: Explicitly call _run_finalizers() to remove immediately
    # temporary directories created by multiprocessing.util.get_temp_dir().
    multiprocessing.util._run_finalizers()
    support.gc_collect()
Esempio n. 18
0
def test_main():
    try:
        test.support.run_unittest(PydocDocTest,
                                  PydocImportTest,
                                  TestDescriptions,
                                  PydocServerTest,
                                  PydocUrlHandlerTest,
                                  TestHelper,
                                  PydocWithMetaClasses,
                                  TestInternalUtilities,
                                  )
    finally:
        reap_children()
Esempio n. 19
0
def _runtest_inner2(ns, test_name):
    # Load the test function, run the test function, handle huntrleaks
    # and findleaks to detect leaks

    abstest = get_abs_module(ns, test_name)

    # remove the module from sys.module to reload it if it was already imported
    try:
        del sys.modules[abstest]
    except KeyError:
        pass

    the_module = importlib.import_module(abstest)

    if ns.huntrleaks:
        from test.libregrtest.refleak import dash_R

    # If the test has a test_main, that will run the appropriate
    # tests.  If not, use normal unittest test loading.
    test_runner = getattr(the_module, "test_main", None)
    if test_runner is None:
        test_runner = functools.partial(_test_module, the_module)

    try:
        with save_env(ns, test_name):
            if ns.huntrleaks:
                # Return True if the test leaked references
                refleak = dash_R(ns, test_name, test_runner)
            else:
                test_runner()
                refleak = False
    finally:
        cleanup_test_droppings(test_name, ns.verbose)

    support.gc_collect()

    if gc.garbage:
        support.environment_altered = True
        print_warning(f"{test_name} created {len(gc.garbage)} "
                      f"uncollectable object(s).")

        # move the uncollectable objects somewhere,
        # so we don't see them again
        FOUND_GARBAGE.extend(gc.garbage)
        gc.garbage.clear()

    support.reap_children()

    return refleak
Esempio n. 20
0
 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()
Esempio n. 21
0
 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()
Esempio n. 22
0
def _cleanup_tests():
    """Cleanup multiprocess resources when multiprocess tests
    completed."""

    from test import support

    # cleanup multiprocessing
    process._cleanup()

    # Stop the ForkServer process if it's running
    from multiprocess import forkserver
    forkserver._forkserver._stop()

    # bpo-37421: Explicitly call _run_finalizers() to remove immediately
    # temporary directories created by multiprocessing.util.get_temp_dir().
    _run_finalizers()
    support.gc_collect()

    support.reap_children()
Esempio n. 23
0
    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() + support.SHORT_TIMEOUT

        was_altered = support.environment_altered
        try:
            support.environment_altered = False
            stderr = io.StringIO()

            while True:
                if time.monotonic() > deadline:
                    self.fail("timeout")

                old_stderr = sys.__stderr__
                try:
                    sys.__stderr__ = stderr
                    support.reap_children()
                finally:
                    sys.__stderr__ = old_stderr

                # 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()
Esempio n. 24
0
    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()
Esempio n. 25
0
def test_main():
    tests = [DefaultSelectorTestCase, SelectSelectorTestCase,
             PollSelectorTestCase, EpollSelectorTestCase,
             KqueueSelectorTestCase]
    support.run_unittest(*tests)
    support.reap_children()
Esempio n. 26
0
def test_main():
    support.run_unittest(SelectTestCase)
    support.reap_children()
Esempio n. 27
0
def test_main():
    run_unittest(SimplePipeTests)
    reap_children()
 def tearDown(self):
     # Try to minimize the number of children we have so this test
     # doesn't crash on some buildbots (Alphas in particular).
     if hasattr(support, "reap_children"):
         support.reap_children()
Esempio n. 29
0
def test_main():
    run_unittest(SimplePipeTests)
    reap_children()
Esempio n. 30
0
def tearDownModule():
    reap_children()
Esempio n. 31
0
def tearDownModule():
    support.reap_children()
Esempio n. 32
0
def test_main():
    support.run_unittest(SelectTestCase)
    support.reap_children()
Esempio n. 33
0
def test_main():
    run_unittest(ForkTest)
    reap_children()
Esempio n. 34
0
def test_main():
    support.run_unittest(CmdLineTest)
    support.reap_children()
Esempio n. 35
0
def tearDownModule():
    reap_children()
Esempio n. 36
0
def test_main():
    support.run_unittest(BZ2FileTest, BZ2CompressorTest, BZ2DecompressorTest,
                         CompressDecompressTest, OpenTest)
    support.reap_children()
 def setUp(self):
     # Try to minimize the number of children we have so this test
     # doesn't crash on some buildbots (Alphas in particular).
     support.reap_children()
def test_main():
    support.run_unittest(ProcessTestCase, CommandTests)
    support.reap_children()
Esempio n. 39
0
def test_main():
    # used by regrtest
    support.run_unittest(unittest.test.suite())
    support.reap_children()
Esempio n. 40
0
def test_main():
    support.run_unittest(LocaleConfigurationTests, LocaleCoercionTests)
    support.reap_children()
Esempio n. 41
0
def post_test_cleanup():
    support.reap_children()
Esempio n. 42
0
def test_main(verbose=None):
    try:
        run_unittest(SmallPtyTests, PtyTest)
    finally:
        reap_children()
Esempio n. 43
0
 def tearDown(self):
     support.threading_cleanup(*self._threads)
     support.reap_children()
Esempio n. 44
0
def test_main(verbose=None):
    try:
        run_unittest(SmallPtyTests, PtyTest)
    finally:
        reap_children()
Esempio n. 45
0
def post_test_cleanup():
    support.reap_children()
Esempio n. 46
0
def test_main():
    support.run_unittest(CmdLineTest, IgnoreEnvironmentTest)
    support.reap_children()
Esempio n. 47
0
def test_main():
    try:
        support.run_unittest(PosixTester, PosixGroupsTester)
    finally:
        support.reap_children()
def test_main():
    support.run_unittest(ProcessTestCase, CommandTests)
    support.reap_children()
Esempio n. 49
0
def test_main():
    run_unittest(Wait3Test)
    reap_children()
Esempio n. 50
0
def test_main():
    # used by regrtest
    support.run_unittest(distutils.tests.test_suite())
    support.reap_children()
Esempio n. 51
0
def test_main():
    support.run_unittest(CmdLineTest)
    support.reap_children()
Esempio n. 52
0
def test_main():
    try:
        support.run_unittest(PosixTester, PosixGroupsTester)
    finally:
        support.reap_children()
Esempio n. 53
0
def test_main():
    support.run_unittest(CmdLineTest, IgnoreEnvironmentTest)
    support.reap_children()
Esempio n. 54
0
def post_test_cleanup():
    support.gc_collect()
    support.reap_children()
def tearDownModule():
    support.reap_children()
Esempio n. 56
0
def test_main():
    tests = [DefaultSelectorTestCase, SelectSelectorTestCase,
             PollSelectorTestCase, EpollSelectorTestCase,
             KqueueSelectorTestCase, DevpollSelectorTestCase]
    support.run_unittest(*tests)
    support.reap_children()
 def tearDown(self):
     support.threading_cleanup(*self._threads)
     support.reap_children()
Esempio n. 58
0
def test_main():
    run_unittest(ForkTest)
    reap_children()