当前位置: 首页>>代码示例>>Python>>正文


Python support.run_unittest方法代码示例

本文整理汇总了Python中test.support.run_unittest方法的典型用法代码示例。如果您正苦于以下问题:Python support.run_unittest方法的具体用法?Python support.run_unittest怎么用?Python support.run_unittest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在test.support的用法示例。


在下文中一共展示了support.run_unittest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_no_tests_ran_multiple_tests_nonexistent

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import run_unittest [as 别名]
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]) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:22,代码来源:test_regrtest.py

示例2: test_failing_test

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import run_unittest [as 别名]
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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:21,代码来源:test_regrtest.py

示例3: test_forever

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import run_unittest [as 别名]
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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:26,代码来源:test_regrtest.py

示例4: test_huntrleaks

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import run_unittest [as 别名]
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') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:test_regrtest.py

示例5: test_huntrleaks_fd_leak

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import run_unittest [as 别名]
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') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:test_regrtest.py

示例6: test_env_changed

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import run_unittest [as 别名]
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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:24,代码来源:test_regrtest.py

示例7: test_no_tests_ran

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import run_unittest [as 别名]
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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:test_regrtest.py

示例8: check_enough_semaphores

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import run_unittest [as 别名]
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
# 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:20,代码来源:test_multiprocessing.py

示例9: test_main

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import run_unittest [as 别名]
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) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:18,代码来源:test_threading_local.py

示例10: test_main

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import run_unittest [as 别名]
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) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:27,代码来源:test_deque.py

示例11: test_main

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import run_unittest [as 别名]
def test_main():
    tests = [TestSupport]
    support.run_unittest(*tests) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:test_test_support.py

示例12: test_main

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import run_unittest [as 别名]
def test_main():
    support.run_unittest(LineCacheTests) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:4,代码来源:test_linecache.py

示例13: test_main

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import run_unittest [as 别名]
def test_main():
    support.run_unittest(MinidomTest) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:4,代码来源:test_minidom.py

示例14: create_test

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import run_unittest [as 别名]
def create_test(self, name=None, code=None):
        if not name:
            name = 'noop%s' % BaseTestCase.TEST_UNIQUE_ID
            BaseTestCase.TEST_UNIQUE_ID += 1

        if code is None:
            code = textwrap.dedent("""
                    import unittest
                    from test import support

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

                    def test_main():
                        support.run_unittest(Tests)
                """)

        # test_regrtest cannot be run twice in parallel because
        # of setUp() and create_test()
        name = self.TESTNAME_PREFIX + name
        path = os.path.join(self.tmptestdir, name + '.py')

        self.addCleanup(support.unlink, path)
        # Use O_EXCL to ensure that we do not override existing tests
        try:
            fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_EXCL)
        except OSError as exc:
            if (exc.errno in (errno.EACCES, errno.EPERM)
               and not sysconfig.is_python_build()):
                self.skipTest("cannot write %s: %s" % (path, exc))
            else:
                raise
        else:
            with os.fdopen(fd, 'w') as fp:
                fp.write(code)
        return name 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:39,代码来源:test_regrtest.py

示例15: test_no_test_ran_some_test_exist_some_not

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import run_unittest [as 别名]
def test_no_test_ran_some_test_exist_some_not(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)
        other_code = textwrap.dedent("""
            import unittest
            from test import support

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

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

        output = self.run_tests("-m", "nosuchtest", "-m", "test_other_bug",
                                testname, testname2,
                                exitcode=0)
        self.check_executed_tests(output, [testname, testname2],
                                  no_test_ran=[testname]) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:33,代码来源:test_regrtest.py


注:本文中的test.support.run_unittest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。