haas package¶
Subpackages¶
Submodules¶
haas.error_holder module¶
haas.exceptions module¶
haas.haas_application module¶
-
class
haas.haas_application.
HaasApplication
(argv, **kwargs)[source]¶ Bases:
object
Main haas application entry-point.
-
run
(plugin_manager=None)[source]¶ 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.
-
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_suite
(tests=())[source]¶ Create a test suite using the confugured test suite class.
Parameters: tests (sequence) – Sequence of TestCase instances.
-
find_test_method_names
(testcase)[source]¶ Return a list of test method names in the provided
TestCase
subclass.Parameters: testcase (type) – Subclass of unittest.TestCase
-
get_test_cases_from_module
(module)[source]¶ Return a list of TestCase subclasses contained in the provided module object.
Parameters: module (module) – A module object containing TestCases
-
load_case
(testcase)[source]¶ Load a TestSuite containing all TestCase instances for all tests in a TestCase subclass.
Parameters: testcase (type) – A subclass of unittest.TestCase
-
haas.main module¶
haas.module_import_error module¶
haas.plugin_context module¶
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
(parser)[source]¶ 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.
-
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.
Parameters: - 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.
Parameters: - 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.
Parameters: - 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.
Parameters: - test (unittest.TestCase) – The test that has completed.
- reason (str) – The reason the test was skipped.
-
addSuccess
(test)[source]¶ 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_result
(result)[source]¶ Add an already-constructed
TestResult
to thisResultCollector
.This may be used when collecting results created by other ResultCollectors (e.g. in subprocesses).
-
separator2
= u'----------------------------------------------------------------------'¶
-
startTest
(test, start_time=None)[source]¶ Indicate that an individual test is starting.
Parameters: - 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.
-
stop
()[source]¶ Set the
shouldStop
flag, used by the test cases to determine if they should terminate early.
-
-
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.
-
duration
¶
-
start_time
¶
-
stop_time
¶
-
total_seconds
¶
-
-
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_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.Parameters: - 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.
-
test
¶ The test case instance this result represents.
-
classmethod
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.
-
haas.suite.
find_test_cases
(suite)[source]¶ 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.