Python test.support.run_unittest() Examples

The following are 30 code examples of test.support.run_unittest(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module test.support , or try the search function .
Example #1
Source File: test_regrtest.py    From ironpython2 with Apache License 2.0 7 votes vote down vote up
def test_forever(self):
        # test --forever
        code = textwrap.dedent("""
            import __builtin__
            import unittest
            from test import support

            class ForeverTester(unittest.TestCase):
                def test_run(self):
                    # Store the state in the __builtin__ module, because the test
                    # module is reload at each run
                    if 'RUN' in __builtin__.__dict__:
                        __builtin__.__dict__['RUN'] += 1
                        if __builtin__.__dict__['RUN'] >= 3:
                            self.fail("fail at the 3rd runs")
                    else:
                        __builtin__.__dict__['RUN'] = 1

            def test_main():
                support.run_unittest(ForeverTester)
        """)
        test = self.create_test('forever', code=code)
        output = self.run_tests('--forever', test, exitcode=2)
        self.check_executed_tests(output, [test]*3, failed=test) 
Example #2
Source File: test_multiprocessing.py    From ironpython2 with Apache License 2.0 6 votes vote down vote up
def check_enough_semaphores():
    """Check that the system supports enough semaphores to run the test."""
    # minimum number of semaphores available according to POSIX
    nsems_min = 256
    try:
        nsems = os.sysconf("SC_SEM_NSEMS_MAX")
    except (AttributeError, ValueError):
        # sysconf not available or setting not available
        return
    if nsems == -1 or nsems >= nsems_min:
        return
    raise unittest.SkipTest("The OS doesn't support enough semaphores "
                            "to run the test (required: %d)." % nsems_min)


#
# Creates a wrapper for a function which records the time it takes to finish
# 
Example #3
Source File: test_threading_local.py    From Fluid-Designer with GNU General Public License v3.0 6 votes vote down vote up
def test_main():
    suite = unittest.TestSuite()
    suite.addTest(DocTestSuite('_threading_local'))
    suite.addTest(unittest.makeSuite(ThreadLocalTest))
    suite.addTest(unittest.makeSuite(PyThreadingLocalTest))

    local_orig = _threading_local.local
    def setUp(test):
        _threading_local.local = _thread._local
    def tearDown(test):
        _threading_local.local = local_orig
    suite.addTest(DocTestSuite('_threading_local',
                               setUp=setUp, tearDown=tearDown)
                  )

    support.run_unittest(suite) 
Example #4
Source File: test_regrtest.py    From ironpython2 with Apache License 2.0 6 votes vote down vote up
def test_failing_test(self):
        # test a failing test
        code = textwrap.dedent("""
            import unittest
            from test import support

            class FailingTest(unittest.TestCase):
                def test_failing(self):
                    self.fail("bug")

            def test_main():
                support.run_unittest(FailingTest)
        """)
        test_ok = self.create_test('ok')
        test_failing = self.create_test('failing', code=code)
        tests = [test_ok, test_failing]

        output = self.run_tests(*tests, exitcode=2)
        self.check_executed_tests(output, tests, failed=test_failing) 
Example #5
Source File: test_regrtest.py    From ironpython2 with Apache License 2.0 6 votes vote down vote up
def test_huntrleaks(self):
        # test --huntrleaks
        code = textwrap.dedent("""
            import unittest
            from test import support

            GLOBAL_LIST = []

            class RefLeakTest(unittest.TestCase):
                def test_leak(self):
                    GLOBAL_LIST.append(object())

            def test_main():
                support.run_unittest(RefLeakTest)
        """)
        self.check_leak(code, 'references') 
Example #6
Source File: test_regrtest.py    From ironpython2 with Apache License 2.0 6 votes vote down vote up
def test_huntrleaks_fd_leak(self):
        # test --huntrleaks for file descriptor leak
        code = textwrap.dedent("""
            import os
            import unittest
            from test import support

            class FDLeakTest(unittest.TestCase):
                def test_leak(self):
                    fd = os.open(__file__, os.O_RDONLY)
                    # bug: never close the file descriptor

            def test_main():
                support.run_unittest(FDLeakTest)
        """)
        self.check_leak(code, 'file descriptors') 
Example #7
Source File: test_regrtest.py    From ironpython2 with Apache License 2.0 6 votes vote down vote up
def test_env_changed(self):
        code = textwrap.dedent("""
            import unittest
            from test import support

            class Tests(unittest.TestCase):
                def test_env_changed(self):
                    open("env_changed", "w").close()

            def test_main():
                support.run_unittest(Tests)
        """)
        testname = self.create_test(code=code)

        # don't fail by default
        output = self.run_tests(testname)
        self.check_executed_tests(output, [testname], env_changed=testname)

        # fail with --fail-env-changed
        output = self.run_tests("--fail-env-changed", testname, exitcode=3)
        self.check_executed_tests(output, [testname], env_changed=testname,
                                  fail_env_changed=True) 
Example #8
Source File: test_regrtest.py    From ironpython2 with Apache License 2.0 6 votes vote down vote up
def test_no_tests_ran(self):
        code = textwrap.dedent("""
            import unittest
            from test import support

            class Tests(unittest.TestCase):
                def test_bug(self):
                    pass

            def test_main():
                support.run_unittest(Tests)
        """)
        testname = self.create_test(code=code)

        output = self.run_tests("-m", "nosuchtest", testname, exitcode=0)
        self.check_executed_tests(output, [testname], no_test_ran=testname) 
Example #9
Source File: test_regrtest.py    From ironpython2 with Apache License 2.0 6 votes vote down vote up
def test_no_tests_ran_multiple_tests_nonexistent(self):
        code = textwrap.dedent("""
            import unittest
            from test import support

            class Tests(unittest.TestCase):
                def test_bug(self):
                    pass

            def test_main():
                support.run_unittest(Tests)
        """)
        testname = self.create_test(code=code)
        testname2 = self.create_test(code=code)

        output = self.run_tests("-m", "nosuchtest",
                                testname, testname2,
                                exitcode=0)
        self.check_executed_tests(output, [testname, testname2],
                                  no_test_ran=[testname, testname2]) 
Example #10
Source File: test_deque.py    From Fluid-Designer with GNU General Public License v3.0 6 votes vote down vote up
def test_main(verbose=None):
    import sys
    test_classes = (
        TestBasic,
        TestVariousIteratorArgs,
        TestSubclass,
        TestSubclassWithKwargs,
        TestSequence,
    )

    support.run_unittest(*test_classes)

    # verify reference counting
    if verbose and hasattr(sys, "gettotalrefcount"):
        import gc
        counts = [None] * 5
        for i in range(len(counts)):
            support.run_unittest(*test_classes)
            gc.collect()
            counts[i] = sys.gettotalrefcount()
        print(counts)

    # doctests
    from test import test_deque
    support.run_doctest(test_deque, verbose) 
Example #11
Source File: test_xmlrpc_net.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def test_main():
    support.requires("network")
    support.run_unittest(PythonBuildersTest) 
Example #12
Source File: test_unittest.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def test_main():
    # used by regrtest
    support.run_unittest(unittest.test.suite())
    support.reap_children() 
Example #13
Source File: test_logging.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def test_main():
    support.run_unittest(
        BuiltinLevelsTest, BasicFilterTest, CustomLevelsAndFiltersTest,
        HandlerTest, MemoryHandlerTest, ConfigFileTest, SocketHandlerTest,
        DatagramHandlerTest, MemoryTest, EncodingTest, WarningsTest,
        ConfigDictTest, ManagerTest, FormatterTest, BufferingFormatterTest,
        StreamHandlerTest, LogRecordFactoryTest, ChildLoggerTest,
        QueueHandlerTest, ShutdownTest, ModuleLevelMiscTest, BasicConfigTest,
        LoggerAdapterTest, LoggerTest, SMTPHandlerTest, FileHandlerTest,
        RotatingFileHandlerTest,  LastResortTest, LogRecordTest,
        ExceptionTest, SysLogHandlerTest, HTTPHandlerTest,
        NTEventLogHandlerTest, TimedRotatingFileHandlerTest,
        UnixSocketHandlerTest, UnixDatagramHandlerTest, UnixSysLogHandlerTest) 
Example #14
Source File: test_weakref.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def test_main():
    support.run_unittest(
        ReferencesTestCase,
        WeakMethodTestCase,
        MappingTestCase,
        WeakValueDictionaryTestCase,
        WeakKeyDictionaryTestCase,
        SubclassableWeakrefTestCase,
        FinalizeTestCase,
        )
    support.run_doctest(sys.modules[__name__]) 
Example #15
Source File: test_multibytecodec.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def test_main():
    support.run_unittest(__name__) 
Example #16
Source File: test_syntax.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def test_main():
    support.run_unittest(SyntaxTestCase)
    from test import test_syntax
    support.run_doctest(test_syntax, verbosity=True) 
Example #17
Source File: test_bool.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def test_main():
    support.run_unittest(BoolTest) 
Example #18
Source File: test_locks.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def test_main():
    support.run_unittest(Frozen_ModuleLockAsRLockTests,
                         Source_ModuleLockAsRLockTests,
                         Frozen_DeadlockAvoidanceTests,
                         Source_DeadlockAvoidanceTests,
                         Frozen_LifetimeTests,
                         Source_LifetimeTests) 
Example #19
Source File: test_tk.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def test_main():
    support.run_unittest(
            *runtktests.get_tests(text=False, packages=['test_tkinter'])) 
Example #20
Source File: test_cmd_line_script.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def test_main():
    support.run_unittest(CmdLineTest)
    support.reap_children() 
Example #21
Source File: test_posix.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def test_main():
    try:
        support.run_unittest(PosixTester, PosixGroupsTester)
    finally:
        support.reap_children() 
Example #22
Source File: test_gettext.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def test_main():
    support.run_unittest(__name__) 
Example #23
Source File: test_cmd.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def test_main(verbose=None):
    from test import test_cmd
    support.run_doctest(test_cmd, verbose)
    support.run_unittest(TestAlternateInput) 
Example #24
Source File: test_poplib.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def test_main():
    tests = [TestPOP3Class, TestTimeouts,
             TestPOP3_SSLClass, TestPOP3_TLSClass]
    thread_info = test_support.threading_setup()
    try:
        test_support.run_unittest(*tests)
    finally:
        test_support.threading_cleanup(*thread_info) 
Example #25
Source File: test_subprocess.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def test_main():
    unit_tests = (ProcessTestCase,
                  POSIXProcessTestCase,
                  Win32ProcessTestCase,
                  CommandTests,
                  ProcessTestCaseNoPoll,
                  CommandsWithSpaces,
                  ContextManagerTests,
                  RunFuncTestCase,
                  )

    support.run_unittest(*unit_tests)
    support.reap_children() 
Example #26
Source File: test_winreg.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def test_main():
    support.run_unittest(LocalWinregTests, RemoteWinregTests,
                         Win64WinregTests) 
Example #27
Source File: test_httpservers.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def test_main(verbose=None):
    cwd = os.getcwd()
    try:
        support.run_unittest(
            RequestHandlerLoggingTestCase,
            BaseHTTPRequestHandlerTestCase,
            BaseHTTPServerTestCase,
            SimpleHTTPServerTestCase,
            CGIHTTPServerTestCase,
            SimpleHTTPRequestHandlerTestCase,
            MiscTestCase,
        )
    finally:
        os.chdir(cwd) 
Example #28
Source File: test_tracemalloc.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def test_main():
    support.run_unittest(
        TestTracemallocEnabled,
        TestSnapshot,
        TestFilters,
        TestCommandLine,
    ) 
Example #29
Source File: test_plistlib.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def test_main():
    support.run_unittest(TestPlistlib, TestPlistlibDeprecated) 
Example #30
Source File: test_resource.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def test_main(verbose=None):
    support.run_unittest(ResourceTest)