gabbi Package¶
case
Module¶
driver
Module¶
suitemaker
Module¶
fixture
Module¶
Manage fixtures for gabbi at the test suite level.
-
class
gabbi.fixture.
GabbiFixture
¶ Bases:
object
A context manager that operates as a fixture.
Subclasses must implement
start_fixture
andstop_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_fixture
andstop_fixture
and 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:
Exception
Generic exception for GabbiFixture.
-
class
gabbi.fixture.
SkipAllFixture
¶ Bases:
gabbi.fixture.GabbiFixture
A fixture that skips all the tests in the current suite.
-
start_fixture
()¶ Implement the actual workings of starting the fixture here.
-
-
gabbi.fixture.
nest
(fixtures)¶ Nest a series of fixtures.
This is duplicated from
nested
in 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 thewith
syntax that replacesnested
will not work.
handlers
Module¶
handlers.base
Module¶
Base classes for response and content handlers.
-
class
gabbi.handlers.base.
ContentHandler
¶ Bases:
gabbi.handlers.base.ResponseHandler
A subclass of ResponseHandlers that adds content handling.
-
static
accepts
(content_type)¶ Return True if this handler can handler this type.
-
static
dumps
(data, pretty=False, test=None)¶ Return structured data as a string.
If pretty is true, prettify.
-
static
load_data_file
(test, file_path)¶ Return the string content of the file specified by the file_path.
-
static
loads
(data)¶ Create structured (Python) data from a stream.
If there is a failure decoding then the handler should repackage the error as a gabbi.exception.GabbiDataLoadError.
-
classmethod
replacer
(response_data, path)¶ Return the string that is replacing RESPONSE.
-
static
-
class
gabbi.handlers.base.
ResponseHandler
¶ Bases:
object
Add functionality for making assertions about an HTTP response.
A subclass may implement two methods:
action
andpreprocess
.preprocess
takes one argument, theTestCase
. It is called exactly once for each test before looping across the assertions. It is used, rarely, to copy thetest.output
into a useful form (such as a parsed DOM).action
takes two or three arguments. Iftest_key_value
is a listaction
is called with the test case and a single list item. Iftest_key_value
is a dict thenaction
is called with the test case and a key and value pair.-
action
(test, item, value=None)¶ Test an individual entry for this response handler.
If the entry is a key value pair the key is in item and the value in value. Otherwise the entry is considered a single item from a list.
-
preprocess
(test)¶ Do any pre-single-test preprocessing.
-
test_key_suffix
= ''¶
-
test_key_value
= []¶
-
handlers.core
Module¶
Core response handlers.
-
class
gabbi.handlers.core.
ForbiddenHeadersResponseHandler
¶ Bases:
gabbi.handlers.base.ResponseHandler
Test that listed headers are not in the response.
-
action
(test, forbidden, value=None)¶ Test an individual entry for this response handler.
If the entry is a key value pair the key is in item and the value in value. Otherwise the entry is considered a single item from a list.
-
test_key_suffix
= 'forbidden_headers'¶
-
test_key_value
= []¶
-
-
class
gabbi.handlers.core.
HeadersResponseHandler
¶ Bases:
gabbi.handlers.base.ResponseHandler
Compare expected headers with actual headers.
If a header value is wrapped in
/
it is treated as a raw regular expression.Headers values are always treated as strings.
-
action
(test, header, value=None)¶ Test an individual entry for this response handler.
If the entry is a key value pair the key is in item and the value in value. Otherwise the entry is considered a single item from a list.
-
test_key_suffix
= 'headers'¶
-
test_key_value
= {}¶
-
-
class
gabbi.handlers.core.
StringResponseHandler
¶ Bases:
gabbi.handlers.base.ResponseHandler
Test for matching strings in the the response body.
-
action
(test, expected, value=None)¶ Test an individual entry for this response handler.
If the entry is a key value pair the key is in item and the value in value. Otherwise the entry is considered a single item from a list.
-
test_key_suffix
= 'strings'¶
-
test_key_value
= []¶
-
handlers.jsonhandler
Module¶
handlers.yaml_disk_loading_jsonhandler
Module¶
suite
Module¶
runner
Module¶
reporter
Module¶
utils
Module¶
exception
Module¶
Gabbi specific exceptions.
-
exception
gabbi.exception.
GabbiDataLoadError
¶ Bases:
ValueError
An exception to alert when data streams cannot be loaded.
-
exception
gabbi.exception.
GabbiFormatError
¶ Bases:
ValueError
An exception to encapsulate poorly formed test data.
-
exception
gabbi.exception.
GabbiSyntaxWarning
¶ Bases:
SyntaxWarning
A warning about syntax that is not desirable.