cafe.drivers.unittest package¶
cafe.drivers.unittest.datasets module¶
-
class
cafe.drivers.unittest.datasets.
DatasetFileLoader
(file_object)[source]¶ Bases:
cafe.drivers.unittest.datasets.DatasetList
Reads a file object’s contents in as json and converts them to lists of Dataset objects. Files should be opened in ‘rb’ (read binady) mode. File should be a list of dictionaries following this format: [{‘name’:”dataset_name”, ‘data’:{key:value, key:value, …}},] if name is ommited, it is replaced with that dataset’s location in the load order, so that not all datasets need to be named.
-
class
cafe.drivers.unittest.datasets.
DatasetGenerator
(list_of_dicts, base_dataset_name=None)[source]¶ Bases:
cafe.drivers.unittest.datasets.DatasetList
Generates Datasets from a list of dictionaries, which are named numericaly according to the source dictionary’s order in the source list. If a base_dataset_name is provided, that is used as the base name postfix for all tests before they are numbered.
-
class
cafe.drivers.unittest.datasets.
DatasetList
[source]¶ Bases:
list
Specialized list-like object that holds Dataset objects
-
append_new_dataset
(name, data_dict, tags=None, decorators=None)[source]¶ Creates and appends a new Dataset
When including a decorators value (a list), make sure that the functions provided in the list are provided in the order in which they should be executed. When comparing them to typical stacked decorators, order them from bottom to top.
Applies tags to all tests in dataset list
-
static
replace_invalid_characters
(string, new_char='_')[source]¶ This functions corrects string so the following is true Identifiers (also referred to as names) are described by the following lexical definitions: identifier ::= (letter|”_”) (letter | digit | “_”)* letter ::= lowercase | uppercase lowercase ::= “a”…”z” uppercase ::= “A”…”Z” digit ::= “0”…”9”
-
-
class
cafe.drivers.unittest.datasets.
DatasetListCombiner
(*datasets)[source]¶ Bases:
cafe.drivers.unittest.datasets.DatasetList
Class that can be used to combine multiple DatasetList objects together. Produces the product of combining every dataset from each list together with the names merged together. The data is overridden in a cascading fashion, similar to CSS, where the last dataset takes priority.
-
class
cafe.drivers.unittest.datasets.
TestMultiplier
(num_range)[source]¶ Bases:
cafe.drivers.unittest.datasets.DatasetList
Creates num_range number of copies of the source test, and names the new tests numerically. Does not generate Datasets.
cafe.drivers.unittest.decorators module¶
-
cafe.drivers.unittest.decorators.
DataDrivenClass
(*dataset_lists)[source]¶ Use data driven class decorator. designed to be used on a fixture.
-
cafe.drivers.unittest.decorators.
DataDrivenFixture
(cls)[source]¶ Generates new unittest test methods from methods defined in the decorated class
-
exception
cafe.drivers.unittest.decorators.
DataDrivenFixtureError
[source]¶ Bases:
exceptions.Exception
Error if you apply DataDrivenClass to class that isn’t a TestCase
-
exception
cafe.drivers.unittest.decorators.
EmptyDSLError
(dsl_namespace, original_test_list)[source]¶ Bases:
exceptions.Exception
Custom exception to allow errors in Datadriven classes with no data.
-
cafe.drivers.unittest.decorators.
data_driven_test
(*dataset_sources, **kwargs)[source]¶ Used to define the data source for a data driven test in a DataDrivenFixture decorated Unittest TestCase class
-
class
cafe.drivers.unittest.decorators.
memoized
(func)[source]¶ Bases:
object
Decorator. @see: https://wiki.python.org/moin/PythonDecoratorLibrary#Memoize Caches a function’s return value each time it is called. If called later with the same arguments, the cached value is returned (not reevaluated).
Adds and removes handlers to root log for the duration of the function call, or logs return of cached result.
Adds tags and attributes to tests, which are interpreted by the cafe-runner at run time
cafe.drivers.unittest.fixtures module¶
@summary: Base Classes for Test Fixtures @note: Corresponds DIRECTLY TO A unittest.TestCase @see: http://docs.python.org/library/unittest.html#unittest.TestCase
-
class
cafe.drivers.unittest.fixtures.
BaseBurnInTestFixture
(methodName='runTest')[source]¶ Bases:
cafe.drivers.unittest.fixtures.BaseTestFixture
@summary: Base test fixture that allows for Burn-In tests
-
class
cafe.drivers.unittest.fixtures.
BaseTestFixture
(methodName='runTest')[source]¶ Bases:
unittest.case.TestCase
- @summary: This should be used as the base class for any unittest tests,
- meant to be used instead of unittest.TestCase.
@see: http://docs.python.org/library/unittest.html#unittest.TestCase
-
classmethod
addClassCleanup
(function, *args, **kwargs)[source]¶ @summary: Named to match unittest’s addCleanup. ClassCleanup tasks run if setUpClass fails, or after tearDownClass. (They don’t depend on tearDownClass running)
-
classmethod
assertClassSetupFailure
(message)[source]¶ - @summary: Use this if you need to fail from a Test Fixture’s
- setUpClass() method
-
classmethod
assertClassTeardownFailure
(message)[source]¶ - @summary: Use this if you need to fail from a Test Fixture’s
- tearUpClass() method
cafe.drivers.unittest.parsers module¶
-
class
cafe.drivers.unittest.parsers.
Result
(test_class_name, test_method_name, failure_trace=None, skipped_msg=None, error_trace=None, test_time=0)[source]¶ Bases:
object
Result object used to create the json and xml results
cafe.drivers.unittest.runner module¶
-
class
cafe.drivers.unittest.runner.
OpenCafeParallelTextTestRunner
(stream=<open file '<stderr>', mode 'w'>, descriptions=1, verbosity=1)[source]¶ Bases:
unittest.runner.TextTestRunner
-
class
cafe.drivers.unittest.runner.
SuiteBuilder
(cl_args, test_repo_name)[source]¶ Bases:
object
cafe.drivers.unittest.suite module¶
Contains a monkeypatched version of unittest’s TestSuite class that supports a version of addCleanup that can be used in classmethods. This allows a more granular approach to teardown to be used in setUpClass and classmethod helper methods