gabbi Package¶
case Module¶
driver Module¶
suitemaker Module¶
fixture Module¶
Manage fixtures for gabbi at the test suite level.
-
class
gabbi.fixture.GabbiFixture¶ Bases:
objectA context manager that operates as a fixture.
Subclasses must implement
start_fixtureandstop_fixture, each of which contain the logic for stopping and starting whatever the fixture is. What a fixture is is left as an exercise for the implementor.These context managers will be nested so any actual work needs to happen in
start_fixtureandstop_fixtureand not in__init__. Otherwise exception handling will not work properly.-
start_fixture()¶ Implement the actual workings of starting the fixture here.
-
stop_fixture()¶ Implement the actual workings of stopping the fixture here.
-
-
exception
gabbi.fixture.GabbiFixtureError¶ Bases:
exceptions.ExceptionGeneric exception for GabbiFixture.
-
class
gabbi.fixture.SkipAllFixture¶ Bases:
gabbi.fixture.GabbiFixtureA fixture that skips all the tests in the current suite.
-
start_fixture()¶
-
-
gabbi.fixture.nest(*args, **kwds)¶ Nest a series of fixtures.
This is duplicated from
nestedin the stdlib, which has been deprecated because of issues with how exceptions are difficult to handle during__init__. Gabbi needs to nest an unknown number of fixtures dynamically, so thewithsyntax that replacesnestedwill not work.
suite Module¶
A TestSuite for containing gabbi tests.
This suite has two features: the contained tests are ordered and there are suite-level fixtures that operate as context managers.
-
class
gabbi.suite.GabbiSuite(tests=())¶ Bases:
unittest.suite.TestSuiteA TestSuite with fixtures.
The suite wraps the tests with a set of nested context managers that operate as fixtures.
If a fixture raises unittest.case.SkipTest during setup, all the tests in this suite will be skipped.
-
run(result, debug=False)¶ Override TestSuite run to start suite-level fixtures.
To avoid exception confusion, use a null Fixture when there are no fixtures.
-
start(result, tests)¶ Start fixtures when using pytest.
-
stop()¶ Stop fixtures when using pytest.
-
-
gabbi.suite.noop(*args)¶ A noop method used to disable collected tests.
runner Module¶
reporter Module¶
TestRunner and TestResult for gabbi-run.
-
class
gabbi.reporter.ConciseTestResult(stream, descriptions, verbosity)¶ Bases:
unittest.runner.TextTestResultA TextTestResult with simple but useful output.
If the output is a tty or GABBI_FORCE_COLOR is set in the environment, output will be colorized.
-
addError(test, err)¶
-
addExpectedFailure(test, err)¶
-
addFailure(test, err)¶
-
addSkip(test, reason)¶
-
addSuccess(test)¶
-
addUnexpectedSuccess(test)¶
-
getDescription(test)¶
-
printErrorList(flavor, errors)¶
-
startTest(test)¶
-
-
class
gabbi.reporter.ConciseTestRunner(stream=<open file '<stderr>', mode 'w'>, descriptions=True, verbosity=1, failfast=False, buffer=False, resultclass=None)¶ Bases:
unittest.runner.TextTestRunnerA TextTestRunner that uses ConciseTestResult for reporting results.
-
resultclass¶ alias of
ConciseTestResult
-
-
class
gabbi.reporter.PyTestResult(stream=None, descriptions=None, verbosity=None)¶ Bases:
unittest.result.TestResultWrap a test result to allow it to work with pytest.
The main behaviors here are:
- to turn what had been exceptions back into exceptions
- use pytest’s skip and xfail methods
-
addError(test, err)¶
-
addExpectedFailure(test, err)¶
-
addFailure(test, err)¶
-
addSkip(test, reason)¶
utils Module¶
Utility functions grab bag.
-
gabbi.utils.create_url(base_url, host, port=None, prefix='', ssl=False)¶ Given pieces of a path-based url, return a fully qualified url.
-
gabbi.utils.decode_response_content(header_dict, content)¶ Decode content to a proper string.
-
gabbi.utils.extract_content_type(header_dict, default='application/binary')¶ Extract parsed content-type from headers.
-
gabbi.utils.get_colorizer(stream)¶ Return a function to colorize a string.
Only if stream is a tty .
-
gabbi.utils.host_info_from_target(target, prefix=None)¶ Turn url or host:port and target into test destination.
-
gabbi.utils.load_yaml(handle=None, yaml_file=None, safe=True)¶ Read and parse any YAML file or filehandle.
Let exceptions flow where they may.
If no file or handle is provided, read from STDIN.
-
gabbi.utils.not_binary(content_type)¶ Decide if something is content we’d like to treat as a string.
-
gabbi.utils.parse_content_type(content_type, default_charset='utf-8')¶ Parse content type value for media type and charset.
exception Module¶
Gabbi specific exceptions.
-
exception
gabbi.exception.GabbiFormatError¶ Bases:
exceptions.ValueErrorAn exception to encapsulate poorly formed test data.
-
exception
gabbi.exception.GabbiSyntaxWarning¶ Bases:
exceptions.SyntaxWarningA warning about syntax that is not desirable.