Ejemplo n.º 1
0
  def from_module(module, name=None):
    """Creates a new test suite out of all of the tests in a module.

    Args:
      module: (module) The module to load the tests from.
      name: (string) The name of the test suite (defaults to module short name).

    Returns:
      TestSuite: The test suite containing the tests from the module.
    """
    name = name if name else modules.find_module_name(module, False)
    description = None
    if hasattr(module, '__doc__'):
      description = module.__doc__
    suite = TestSuite(name, description=description)
    for test in modules.tests_from_module(module).values():
      suite.register(test)
    return suite
Ejemplo n.º 2
0
  def from_module(module=None, module_name=None):
    """Creates a new test run out of all of the tests in a module.

    If module is provided, then that module is used. Otherwise, if module_name
    is defined, then we try to find the module with that name and use that.
    If neither one is provided, then we find the module named '__main__'.

    Args:
      module: (module) The module to load the tests from.
      module_name: (string) The name of the module to load the tests from.

    Returns:
      TestRun: The test run containing the tests from the module.
    """
    if not module_name:
      module_name = '__main__'
    if not module:
      module = sys.modules[module_name]
    test_run = TestRun(modules.find_module_name(module))
    tests = modules.tests_from_module(module)
    for test in tests.values():
      test_run.tests.register(test)
    return test_run
Ejemplo n.º 3
0
    def from_module(module=None, module_name=None):
        """Creates a new test run out of all of the tests in a module.

    If module is provided, then that module is used. Otherwise, if module_name
    is defined, then we try to find the module with that name and use that.
    If neither one is provided, then we find the module named '__main__'.

    Args:
      module: (module) The module to load the tests from.
      module_name: (string) The name of the module to load the tests from.

    Returns:
      TestRun: The test run containing the tests from the module.
    """
        if not module_name:
            module_name = '__main__'
        if not module:
            module = sys.modules[module_name]
        test_run = TestRun(modules.find_module_name(module))
        tests = modules.tests_from_module(module)
        for test in tests.values():
            test_run.tests.register(test)
        return test_run