haas package


haas.error_holder module

class haas.error_holder.ErrorHolder(description)[source]

Bases: object

Placeholder for a TestCase inside a result. As far as a TestResult is concerned, this looks exactly like a unit test. Used to insert arbitrary errors into a test suite run.

failureException = None

haas.exceptions module

exception haas.exceptions.DotInModuleNameError[source]

Bases: haas.exceptions.HaasException

exception haas.exceptions.HaasException[source]

Bases: exceptions.Exception

exception haas.exceptions.PluginError[source]

Bases: haas.exceptions.HaasException

haas.haas_application module

class haas.haas_application.HaasApplication(argv, **kwargs)[source]

Bases: object

Main haas application entry-point.


Run the haas test runner.

This will load and configure the selected plugins, set up the environment and begin test discovery, loading and running.

Parameters:plugin_manager (haas.plugin_manager.PluginManager) – [Optional] Override the use of the default plugin manager.

Creates the argument parser for haas.

haas.loader module

class haas.loader.Loader(test_suite_class=None, test_case_class=None, test_method_prefix=u'test', **kwargs)[source]

Bases: object

Load individual test cases from modules and wrap them in the Suite container.


Create a test suite using the confugured test suite class.

Parameters:tests (sequence) – Sequence of TestCase instances.

Return a list of test method names in the provided TestCase subclass.

Parameters:testcase (type) – Subclass of unittest.TestCase

Return a list of TestCase subclasses contained in the provided module object.

Parameters:module (module) – A module object containing TestCases

Check if a class is a TestCase.


Load a TestSuite containing all TestCase instances for all tests in a TestCase subclass.

Parameters:testcase (type) – A subclass of unittest.TestCase

Create and return a test suite containing all cases loaded from the provided module.

Parameters:module (module) – A module object containing TestCases
load_test(testcase, method_name)[source]

Create and return an instance of unittest.TestCase for the specified unbound test method.

unbound_test : unbound method
An unbound method of a unittest.TestCase

haas.main module


Execute haas.

Parameters:argv (list) – The script’s full argument list including the script itself.

haas.module_import_error module

class haas.module_import_error.ModuleImportError[source]

Bases: object

A base class for generated ModuleImportError placeholder test cases.

haas.plugin_context module

class haas.plugin_context.PluginContext(hooks=None, **kwargs)[source]

Bases: object

Handles correct setup and teardown of multiple plugins.


haas.plugin_manager module

class haas.plugin_manager.PluginManager[source]

Bases: object

ENVIRONMENT_HOOK = u'haas.hooks.environment'
RESULT_HANDLERS = u'haas.result.handler'
TEST_DISCOVERY = u'haas.discovery'
TEST_RUNNER = u'haas.runner'

Add plugin arguments to argument parser.

Parameters:parser (argparse.ArgumentParser) – The main haas ArgumentParser.
get_driver(namespace, parsed_args, **kwargs)[source]

Get mutually-exlusive plugin for plugin namespace.

get_enabled_hook_plugins(hook, args, **kwargs)[source]

Get enabled plugins for specified hook name.

classmethod testing_plugin_manager(hook_managers, driver_managers)[source]

Create a fabricated plugin manager for testing.

haas.result module

class haas.result.ResultCollecter(*args, **kwargs)[source]

Bases: haas.result.ResultCollector

class haas.result.ResultCollector(buffer=False, failfast=False)[source]

Bases: object

Collecter for test results. This handles creating TestResult instances and handing them off the registered result output handlers.

addError(*args, **kw)[source]

Register that a test ended in an error.

  • test (unittest.TestCase) – The test that has completed.
  • exception (tuple) – exc_info tuple (type, value, traceback).
addExpectedFailure(test, exception)[source]

Register that a test that failed and was expected to fail.

  • test (unittest.TestCase) – The test that has completed.
  • exception (tuple) – exc_info tuple (type, value, traceback).
addFailure(*args, **kw)[source]

Register that a test ended with a failure.

  • test (unittest.TestCase) – The test that has completed.
  • exception (tuple) – exc_info tuple (type, value, traceback).
addSkip(test, reason)[source]

Register that a test that was skipped.

  • test (unittest.TestCase) – The test that has completed.
  • reason (str) – The reason the test was skipped.

Register that a test ended in success.

Parameters:test (unittest.TestCase) – The test that has completed.
addUnexpectedSuccess(*args, **kw)[source]

Register a test that passed unexpectedly.

Parameters:test (unittest.TestCase) – The test that has completed.

Add an already-constructed TestResult to this ResultCollector.

This may be used when collecting results created by other ResultCollectors (e.g. in subprocesses).


Register a new result handler.

separator2 = u'----------------------------------------------------------------------'
startTest(test, start_time=None)[source]

Indicate that an individual test is starting.

  • test (unittest.TestCase) – The test that is starting.
  • start_time (datetime) – An internal parameter to allow the parallel test runner to set the actual start time of a test run in a subprocess.

Indicate that the test run is starting.


Set the shouldStop flag, used by the test cases to determine if they should terminate early.


Indicate that an individual test has completed.

Parameters:test (unittest.TestCase) – The test that has completed.

Indicate that the test run has completed.


Return True if the run was successful.

class haas.result.TestCompletionStatus[source]

Bases: enum.Enum

Enumeration to represent the status of a single test.

error = 3

The test encountered an unexpected error.

expected_failure = 5

A test failed as expected

failure = 2

The test failed, but did not encounter an unexpected error.

skipped = 6

A test was skipped

success = 1

The test completed successfully.

unexpected_success = 4

A test marked as expected to fail unexpected passed.

class haas.result.TestDuration(start_time, stop_time=None)[source]

Bases: object

An orderable representation of the duration of an individual test.

class haas.result.TestResult(test_class, test_method_name, status, duration, exception=None, message=None)[source]

Bases: object

Container object for all information related to the run of a single test. This contains the test itself, the actual status including the reason or error associated with status, along with timing information.

classmethod from_dict(data)[source]

Create a TestResult from a dictionary created by to_dict()

classmethod from_test_case(test_case, status, duration, exception=None, message=None, stdout=None, stderr=None)[source]

Construct a TestResult object from the test and a status.

  • test_case (unittest.TestCase) – The test that this result will represent.
  • status (haas.result.TestCompletionStatus) – The status of the test.
  • exception (tuple) – exc_info tuple (type, value, traceback).
  • message (str) – Optional message associated with the result (e.g. skip reason).
  • stdout (str) – The test stdout if stdout was buffered.
  • stderr (str) – The test stderr if stderr was buffered.

The test case instance this result represents.


Serialize the TestResult to a dictionary.


haas.suite module

class haas.suite.TestSuite(tests=())[source]

Bases: object

A TestSuite is a container of test cases and allows executing many test cases while managing the state of the overall suite.


Return the total number of tests contained in this suite.

run(result, _state=None)[source]

Run all tests in the suite.

Parameters:result (unittest.result.TestResult) –

Generate a list of all test cases contained in a test suite.

Parameters:suite (haas.suite.TestSuite) – The test suite from which to generate the test case list.

haas.testing module

haas.utils module

class haas.utils.abstractclassmethod(callable)[source]

Bases: classmethod

A decorator indicating abstract classmethods.

Similar to abstractmethod.


class C(metaclass=ABCMeta):

@abstractclassmethod def my_abstract_classmethod(cls, …):

class haas.utils.cd(destdir)[source]

Bases: object


Import a module and return the imported module object.

haas.utils.uncamelcase(string, sep=u'_')[source]