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


Python TestSuite.addTests方法代码示例

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


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

示例1: load_tests

# 需要导入模块: from unittest.suite import TestSuite [as 别名]
# 或者: from unittest.suite.TestSuite import addTests [as 别名]
def load_tests(loader, tests, pattern):
    suite = TestSuite()
    suite.addTests(load_testsuite(loader, dirname(__file__)))
    # Numba CUDA tests are located in a separate directory:
    cuda_dir = join(dirname(dirname(__file__)), 'cuda/tests')
    suite.addTests(loader.discover(cuda_dir))
    return suite
开发者ID:Alexhuszagh,项目名称:numba,代码行数:9,代码来源:__init__.py

示例2: load_tests_from_classes

# 需要导入模块: from unittest.suite import TestSuite [as 别名]
# 或者: from unittest.suite.TestSuite import addTests [as 别名]
def load_tests_from_classes(test_cases):
    suite = TestSuite()
    loader = TestLoader()
    for test_class in test_cases:
        tests = loader.loadTestsFromTestCase(test_class)
        suite.addTests(tests)
    return suite
开发者ID:orenlivne,项目名称:ober,代码行数:9,代码来源:test_util.py

示例3: _get_suite

# 需要导入模块: from unittest.suite import TestSuite [as 别名]
# 或者: from unittest.suite.TestSuite import addTests [as 别名]
    def _get_suite(self, test_labels, discover_kwargs, extra_tests, methods):
        suite = TestSuite()
        for label in test_labels:
            kwargs = discover_kwargs.copy()
            tests = None

            label_as_path = os.path.abspath(label)

            # if a module, or "module.ClassName[.method_name]", just run those
            if not os.path.exists(label_as_path):
                tests = self.test_loader.loadTestsFromName(label)
            elif os.path.isdir(label_as_path) and not self.top_level:
                # Try to be a bit smarter than unittest about finding the
                # default top-level for a given directory path, to avoid
                # breaking relative imports. (Unittest's default is to set
                # top-level equal to the path, which means relative imports
                # will result in "Attempted relative import in non-package.").

                # We'd be happy to skip this and require dotted module paths
                # (which don't cause this problem) instead of file paths (which
                # do), but in the case of a directory in the cwd, which would
                # be equally valid if considered as a top-level module or as a
                # directory path, unittest unfortunately prefers the latter.

                top_level = label_as_path
                while True:
                    init_py = os.path.join(top_level, '__init__.py')
                    if os.path.exists(init_py):
                        try_next = os.path.dirname(top_level)
                        if try_next == top_level:
                            # __init__.py all the way down? give up.
                            break
                        top_level = try_next
                        continue
                    break
                kwargs['top_level_dir'] = top_level

            if not (tests and tests.countTestCases()):
                # if no tests found, it's probably a package; try discovery
                tests = self.test_loader.discover(start_dir=label, **kwargs)

                # make unittest forget the top-level dir it calculated from this
                # run, to support running tests from two different top-levels.
                self.test_loader._top_level_dir = None

            tests = self.get_tests_defined_in_methods_or_none(tests, methods)
            if tests:
                suite.addTests(tests)

        for test in extra_tests:
            suite.addTest(test)
        return suite
开发者ID:druids,项目名称:django-juno-testrunner,代码行数:54,代码来源:runner.py

示例4: run

# 需要导入模块: from unittest.suite import TestSuite [as 别名]
# 或者: from unittest.suite.TestSuite import addTests [as 别名]
 def run(self):
     global THIS_PATH, PKG_DIR, TEST_DIR
     
     sys.path.insert(0, PKG_DIR)
     
     suite = TestSuite()
     loaded = unittest.defaultTestLoader.discover(TEST_DIR, pattern='*Test.py')
     
     for all_test_suite in loaded:
         for test_suite in all_test_suite:
             suite.addTests(test_suite)
     
     runner = TextTestRunner(verbosity = 2)
     runner.run(suite)
开发者ID:moisespsena,项目名称:py-sdag,代码行数:16,代码来源:setup.py

示例5: assert

# 需要导入模块: from unittest.suite import TestSuite [as 别名]
# 或者: from unittest.suite.TestSuite import addTests [as 别名]
    assert(self.device.GetPin(self.LED1).toChar() == "H")
    assert(self.device.GetPin(self.LED2).toChar() == "H")
    self.doRun(2500000) # 25ms
    assert(self.device.GetPin(self.LED1).toChar() == "H")
    assert(self.device.GetPin(self.LED2).toChar() == "H")
    # Deuxieme seconde
    self.doRun(2500000) # 25ms
    assert(self.device.GetPin(self.LED1).toChar() == "L")
    assert(self.device.GetPin(self.LED2).toChar() == "H")
    self.doRun(2500000) # 25ms
    assert(self.device.GetPin(self.LED1).toChar() == "L")
    assert(self.device.GetPin(self.LED2).toChar() == "H")
    self.doRun(2500000) # 25ms
    assert(self.device.GetPin(self.LED1).toChar() == "L")
    assert(self.device.GetPin(self.LED2).toChar() == "H")
    self.doRun(2500000) # 25ms
    assert(self.device.GetPin(self.LED1).toChar() == "L")
    assert(self.device.GetPin(self.LED2).toChar() == "H")
    self.doRun(2500000) # 25ms
    assert(self.device.GetPin(self.LED1).toChar() == "L")
    assert(self.device.GetPin(self.LED2).toChar() == "L")



if __name__ == "__main__":
  allTestsFrom = defaultTestLoader.loadTestsFromTestCase
  suite = TestSuite()
  suite.addTests(allTestsFrom(TestEx1Semaine2))
  TextTestRunner(verbosity = 2).run(suite)

开发者ID:nka11,项目名称:coursera-uC,代码行数:31,代码来源:s2ex1.py

示例6: load_tests

# 需要导入模块: from unittest.suite import TestSuite [as 别名]
# 或者: from unittest.suite.TestSuite import addTests [as 别名]
def load_tests(loader, tests, pattern):
    suite = TestSuite()
    suite.addTests(load_testsuite(loader, dirname(__file__)))
    return suite
开发者ID:MatthieuDartiailh,项目名称:numba,代码行数:6,代码来源:__init__.py

示例7: load_tests

# 需要导入模块: from unittest.suite import TestSuite [as 别名]
# 或者: from unittest.suite.TestSuite import addTests [as 别名]
def load_tests(loader, tests, pattern):
    suite = TestSuite()
    for test_module in test_cases:
        tests = loader.loadTestsFromModule(test_module)
        suite.addTests(tests)
    return suite
开发者ID:jclmns,项目名称:chisubmit,代码行数:8,代码来源:__init__.py

示例8: TestSuite

# 需要导入模块: from unittest.suite import TestSuite [as 别名]
# 或者: from unittest.suite.TestSuite import addTests [as 别名]
'''
Created on 15 aout 2013

@author: ju
'''

import unittest
from unittest.suite import TestSuite

if __name__ == '__main__':
    suite = TestSuite()
    loader = unittest.TestLoader()
    suite.addTests(loader.discover(start_dir="test", pattern="*test.py"))
    
    unittest.TextTestRunner(verbosity=1).run(suite)
开发者ID:jlerme,项目名称:pycards,代码行数:17,代码来源:testsuite.py


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