haas.plugins package

Submodules

haas.plugins.base_hook_plugin module

class haas.plugins.base_hook_plugin.BaseHookPlugin(name, enabled, enabling_option)[source]

Bases: haas.plugins.i_hook_plugin.IHookPlugin

The base implementation of hook plugins.

classmethod add_parser_arguments(parser, name, option_prefix, dest_prefix)[source]
classmethod from_args(args, name, dest_prefix)[source]

haas.plugins.coverage module

class haas.plugins.coverage.Coverage(*args, **kwargs)[source]

Bases: haas.plugins.base_hook_plugin.BaseHookPlugin

setup()[source]
teardown()[source]

haas.plugins.discoverer module

class haas.plugins.discoverer.Discoverer(loader, **kwargs)[source]

Bases: haas.plugins.i_discoverer_plugin.IDiscovererPlugin

The Discoverer is responsible for finding tests that can be loaded by a Loader.

classmethod add_parser_arguments(parser, option_prefix, dest_prefix)[source]

Add options for the plugin to the main argument parser.

Parameters:
  • parser (argparse.ArgumentParser) – The parser to extend
  • option_prefix (str) – The prefix that option strings added by this plugin should use.
  • dest_prefix (str) – The prefix that dest strings for options added by this plugin should use.
discover(start, top_level_directory=None, pattern=u'test*.py')[source]

Do test case discovery.

This is the top-level entry-point for test discovery.

If the start argument is a drectory, then haas will discover all tests in the package contained in that directory.

If the start argument is not a directory, it is assumed to be a package or module name and tests in the package or module are loaded.

FIXME: This needs a better description.

Parameters:
  • start (str) – The directory, package, module, class or test to load.
  • top_level_directory (str) – The path to the top-level directoy of the project. This is the parent directory of the project’stop-level Python package.
  • pattern (str) – The glob pattern to match the filenames of modules to search for tests.
discover_by_directory(start_directory, top_level_directory=None, pattern=u'test*.py')[source]

Run test discovery in a directory.

Parameters:
  • start_directory (str) – The package directory in which to start test discovery.
  • top_level_directory (str) – The path to the top-level directoy of the project. This is the parent directory of the project’stop-level Python package.
  • pattern (str) – The glob pattern to match the filenames of modules to search for tests.
discover_by_file(start_filepath, top_level_directory=None)[source]

Run test discovery on a single file.

Parameters:
  • start_filepath (str) – The module file in which to start test discovery.
  • top_level_directory (str) – The path to the top-level directoy of the project. This is the parent directory of the project’stop-level Python package.
discover_by_module(module_name, top_level_directory=None, pattern=u'test*.py')[source]

Find all tests in a package or module, or load a single test case if a class or test inside a module was specified.

Parameters:
  • module_name (str) – The dotted package name, module name or TestCase class and test method.
  • top_level_directory (str) – The path to the top-level directoy of the project. This is the parent directory of the project’stop-level Python package.
  • pattern (str) – The glob pattern to match the filenames of modules to search for tests.
discover_filtered_tests(filter_name, top_level_directory=None, pattern=u'test*.py')[source]

Find all tests whose package, module, class or method names match the filter_name string.

Parameters:
  • filter_name (str) – A subsection of the full dotted test name. This can be simply a test method name (e.g. test_some_method), the TestCase class name (e.g. TestMyClass), a module name (e.g. test_module), a subpackage (e.g. tests). It may also be a dotted combination of the above (e.g. TestMyClass.test_some_method).
  • top_level_directory (str) – The path to the top-level directoy of the project. This is the parent directory of the project’stop-level Python package.
  • pattern (str) – The glob pattern to match the filenames of modules to search for tests.
discover_single_case(module, case_attributes)[source]

Find and load a single TestCase or TestCase method from a module.

Parameters:
  • module (module) – The imported Python module containing the TestCase to be loaded.
  • case_attributes (list) – A list (length 1 or 2) of str. The first component must be the name of a TestCase subclass. The second component must be the name of a method in the TestCase.
classmethod from_args(args, arg_prefix, loader)[source]

Construct the discoverer from parsed command line arguments.

Parameters:
  • args (argparse.Namespace) – The argparse.Namespace containing parsed arguments.
  • arg_prefix (str) – The prefix used for arguments beloning solely to this plugin.
  • loader (haas.loader.Loader) – The test loader used to construct TestCase and TestSuite instances.
haas.plugins.discoverer.assert_start_importable(top_level_directory, start_directory)[source]
haas.plugins.discoverer.filter_test_suite(suite, filter_name)[source]

Filter test cases in a test suite by a substring in the full dotted test name.

Parameters:
  • suite (haas.suite.TestSuite) – The test suite containing tests to be filtered.
  • filter_name (str) – The substring of the full dotted name on which to filter. This should not contain a leading or trailing dot.
haas.plugins.discoverer.find_module_by_name(full_name)[source]
haas.plugins.discoverer.find_top_level_directory(start_directory)[source]

Finds the top-level directory of a project given a start directory inside the project.

Parameters:start_directory (str) – The directory in which test discovery will start.
haas.plugins.discoverer.get_module_name(top_level_directory, filepath)[source]
haas.plugins.discoverer.get_relpath(top_level_directory, fullpath)[source]
haas.plugins.discoverer.match_path(filename, filepath, pattern)[source]

haas.plugins.i_hook_plugin module

class haas.plugins.i_hook_plugin.IHookPlugin[source]

Bases: object

classmethod add_parser_arguments(parser, name, option_prefix, dest_prefix)[source]
classmethod from_args(args, dest_prefix)[source]
setup()[source]
teardown()[source]

haas.plugins.i_result_handler_plugin module

class haas.plugins.i_result_handler_plugin.IResultHandlerPlugin[source]

Bases: object

classmethod add_parser_arguments(parser, name, option_prefix, dest_prefix)[source]

Add options for the plugin to the main argument parser.

Parameters:
  • parser (argparse.ArgumentParser) – The parser to extend
  • name (str) – The name of the plugin.
  • option_prefix (str) – The prefix that option strings added by this plugin should use.
  • dest_prefix (str) – The prefix that dest strings for options added by this plugin should use.
classmethod from_args(args, name, dest_prefix, test_count)[source]

Construct the result handler from parsed command line arguments.

Parameters:
  • args (argparse.Namespace) – The argparse.Namespace containing parsed arguments.
  • name (str) – The name of the plugin.
  • dest_prefix (str) – The prefix that dest strings for options added by this plugin should use.
  • test_count (int) – The totel number of tests discovered.
start_test(test)[source]

Perform tasks at the start of a single test.

start_test_run()[source]

Perform tasks at the very start of the test run.

stop_test(test)[source]

Perform tasks at the end of a single test.

stop_test_run()[source]

Perform tasks at the very end of the test run.

haas.plugins.i_runner_plugin module

class haas.plugins.i_runner_plugin.IRunnerPlugin[source]

Bases: object

classmethod add_parser_arguments(parser, option_prefix, dest_prefix)[source]

Add options for the plugin to the main argument parser.

Parameters:
  • parser (argparse.ArgumentParser) – The parser to extend
  • option_prefix (str) – The prefix that option strings added by this plugin should use.
  • dest_prefix (str) – The prefix that dest strings for options added by this plugin should use.
classmethod from_args(args, arg_prefix)[source]

Construct the runner from parsed command line arguments.

Parameters:
  • args (argparse.Namespace) – The argparse.Namespace containing parsed arguments.
  • arg_prefix (str) – The prefix used for arguments beloning solely to this plugin.

haas.plugins.result_handler module

class haas.plugins.result_handler.QuietTestResultHandler(test_count)[source]

Bases: haas.plugins.i_result_handler_plugin.IResultHandlerPlugin

classmethod add_parser_arguments(parser, name, option_prefix, dest_prefix)[source]
classmethod from_args(args, name, dest_prefix, test_count)[source]
get_test_description(test)[source]
print_error_list(error_kind, errors)[source]

Print the list of errors or failures.

Parameters:
  • error_kind (str) – 'ERROR' or 'FAIL'
  • errors (list) – List of TestResult
print_errors()[source]

Print all errors and failures to the console.

print_summary()[source]
separator1 = u'======================================================================'
separator2 = u'----------------------------------------------------------------------'
start_test(test)[source]
start_test_run()[source]
stop_test(test)[source]
stop_test_run()[source]
was_successful()[source]
class haas.plugins.result_handler.StandardTestResultHandler(test_count)[source]

Bases: haas.plugins.result_handler.QuietTestResultHandler

classmethod from_args(args, name, dest_prefix, test_count)[source]
class haas.plugins.result_handler.TimingResultHandler(number_to_summarize)[source]

Bases: haas.plugins.i_result_handler_plugin.IResultHandlerPlugin

OPTION_DEFAULT = <object object>
classmethod add_parser_arguments(parser, name, option_prefix, dest_prefix)[source]
classmethod from_args(args, name, dest_prefix, test_count)[source]
print_summary()[source]
separator1 = u'======================================================================'
separator2 = u'----------------------------------------------------------------------'
start_test(test)[source]
start_test_run()[source]
stop_test(test)[source]
stop_test_run()[source]
class haas.plugins.result_handler.VerboseTestResultHandler(test_count)[source]

Bases: haas.plugins.result_handler.StandardTestResultHandler

classmethod from_args(args, name, dest_prefix, test_count)[source]
start_test(test)[source]
haas.plugins.result_handler.get_test_description(test, descriptions=True)[source]
haas.plugins.result_handler.sort_result_handlers(handlers)[source]

haas.plugins.runner module

class haas.plugins.runner.BaseTestRunner(warnings=None)[source]

Bases: haas.plugins.i_runner_plugin.IRunnerPlugin

A test runner class that does not print any output itself.

classmethod add_parser_arguments(parser, option_prefix, dest_prefix)[source]
classmethod from_args(args, arg_prefix)[source]
run(result_collector, test)[source]

Run the given test case or test suite.