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


Python testscenarios.generate_scenarios方法代码示例

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


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

示例1: test_module_level

# 需要导入模块: import testscenarios [as 别名]
# 或者: from testscenarios import generate_scenarios [as 别名]
def test_module_level(self):
        load_tests = test_fixtures.optimize_module_test_loader()

        loader = unittest.TestLoader()

        found_tests = loader.discover(start_dir, pattern="test_fixtures.py")
        new_loader = load_tests(loader, found_tests, "test_fixtures.py")

        self.assertTrue(
            isinstance(new_loader, testresources.OptimisingTestSuite)
        )

        actual_tests = unittest.TestSuite(
            testscenarios.generate_scenarios(found_tests)
        )

        self.assertEqual(
            new_loader.countTestCases(), actual_tests.countTestCases()
        ) 
开发者ID:openstack,项目名称:oslo.db,代码行数:21,代码来源:test_fixtures.py

示例2: _test_package_level

# 需要导入模块: import testscenarios [as 别名]
# 或者: from testscenarios import generate_scenarios [as 别名]
def _test_package_level(self, fn):
        load_tests = fn(
            os.path.join(start_dir, "__init__.py"))

        loader = unittest.TestLoader()

        new_loader = load_tests(
            loader, unittest.suite.TestSuite(), "test_fixtures.py")

        self.assertTrue(
            isinstance(new_loader, testresources.OptimisingTestSuite)
        )

        actual_tests = unittest.TestSuite(
            testscenarios.generate_scenarios(
                loader.discover(start_dir, pattern="test_fixtures.py"))
        )

        self.assertEqual(
            new_loader.countTestCases(), actual_tests.countTestCases()
        ) 
开发者ID:openstack,项目名称:oslo.db,代码行数:23,代码来源:test_fixtures.py

示例3: makeTest

# 需要导入模块: import testscenarios [as 别名]
# 或者: from testscenarios import generate_scenarios [as 别名]
def makeTest(self, obj, parent):
        """Attempt to expand test scenarios in the given test or tests.

        If `obj` is a test case class, this loads tests and expands scenarios.

        If `parent` is a test case class, this assumes that `obj` is a method,
        instantiates the test case, then expands scenarios.

        Everything else is ignored so the loader that invoked this will revert
        to its default behaviour.
        """
        # obj may be a test case class.
        if isinstance(obj, type):
            if issubclass(obj, unittest.TestCase):
                loader = self._getTestLoader()
                tests = loader.loadTestsFromTestCase(obj)
                tests = map(self._unwrapTest, tests)
                return generate_scenarios(tests)
        # obj may be a function/method.
        elif isinstance(parent, type):
            if issubclass(parent, unittest.TestCase):
                test = parent(obj.__name__)
                return generate_scenarios(test) 
开发者ID:maas,项目名称:maas,代码行数:25,代码来源:noseplug.py

示例4: load_tests

# 需要导入模块: import testscenarios [as 别名]
# 或者: from testscenarios import generate_scenarios [as 别名]
def load_tests(loader, standard_tests, pattern):
    # top level directory cached on loader instance
    this_dir = os.path.dirname(__file__)
    package_tests = loader.discover(start_dir=this_dir, pattern=pattern)
    result = loader.suiteClass()
    result.addTests(testscenarios.generate_scenarios(standard_tests))
    result.addTests(testscenarios.generate_scenarios(package_tests))
    return result 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:10,代码来源:__init__.py

示例5: optimize_package_test_loader

# 需要导入模块: import testscenarios [as 别名]
# 或者: from testscenarios import generate_scenarios [as 别名]
def optimize_package_test_loader(file_):
    """Organize package-level tests into a testresources.OptimizingTestSuite.

    This function provides a unittest-compatible load_tests hook
    for a given package; for per-module, use the
    :func:`.optimize_module_test_loader` function.

    When a unitest or subunit style
    test runner is used, the function will be called in order to
    return a TestSuite containing the tests to run; this function
    ensures that this suite is an OptimisingTestSuite, which will organize
    the production of test resources across groups of tests at once.

    The function is invoked as::

        from oslo_db.sqlalchemy import test_base

        load_tests = test_base.optimize_package_test_loader(__file__)

    The loader *must* be present in the package level __init__.py.

    The function also applies testscenarios expansion to all  test collections.
    This so that an existing test suite that already needs to build
    TestScenarios from a load_tests call can still have this take place when
    replaced with this function.

    """

    this_dir = os.path.dirname(file_)

    def load_tests(loader, found_tests, pattern):
        result = testresources.OptimisingTestSuite()
        result.addTests(found_tests)
        pkg_tests = loader.discover(start_dir=this_dir, pattern=pattern)
        result.addTests(testscenarios.generate_scenarios(pkg_tests))

        return result
    return load_tests 
开发者ID:openstack,项目名称:oslo.db,代码行数:40,代码来源:test_fixtures.py

示例6: optimize_module_test_loader

# 需要导入模块: import testscenarios [as 别名]
# 或者: from testscenarios import generate_scenarios [as 别名]
def optimize_module_test_loader():
    """Organize module-level tests into a testresources.OptimizingTestSuite.

    This function provides a unittest-compatible load_tests hook
    for a given module; for per-package, use the
    :func:`.optimize_package_test_loader` function.

    When a unitest or subunit style
    test runner is used, the function will be called in order to
    return a TestSuite containing the tests to run; this function
    ensures that this suite is an OptimisingTestSuite, which will organize
    the production of test resources across groups of tests at once.

    The function is invoked as::

        from oslo_db.sqlalchemy import test_base

        load_tests = test_base.optimize_module_test_loader()

    The loader *must* be present in an individual module, and *not* the
    package level __init__.py.

    The function also applies testscenarios expansion to all  test collections.
    This so that an existing test suite that already needs to build
    TestScenarios from a load_tests call can still have this take place when
    replaced with this function.

    """

    def load_tests(loader, found_tests, pattern):
        result = testresources.OptimisingTestSuite()
        result.addTests(testscenarios.generate_scenarios(found_tests))
        return result
    return load_tests 
开发者ID:openstack,项目名称:oslo.db,代码行数:36,代码来源:test_fixtures.py

示例7: __call__

# 需要导入模块: import testscenarios [as 别名]
# 或者: from testscenarios import generate_scenarios [as 别名]
def __call__(self, result=None):
        if self._get_scenarios():
            for test in testscenarios.generate_scenarios(self):
                test.__call__(result)
        else:
            super(WithScenarios, self).__call__(result) 
开发者ID:maas,项目名称:python-libmaas,代码行数:8,代码来源:__init__.py

示例8: __call__

# 需要导入模块: import testscenarios [as 别名]
# 或者: from testscenarios import generate_scenarios [as 别名]
def __call__(self, result=None):
        if self._get_scenarios():
            for test in testscenarios.generate_scenarios(self):
                test.__call__(result)
        else:
            super().__call__(result) 
开发者ID:maas,项目名称:maas,代码行数:8,代码来源:scenarios.py


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