Abstract Repository Class

Storage of test results.

A Repository provides storage and indexing of results.

The AbstractRepository class defines the contract to which any Repository implementation must adhere.

The stestr.repository.file module (see: File Repository Type is the usual repository that will be used. The stestr.repository.memory module (see: Memory Repository Type) provides a memory only repository useful for internal testing.

Repositories are identified by their URL, and new ones are made by calling the initialize function in the appropriate repository module.

class stestr.repository.abstract.AbstractRepository[source]

The base class for Repository implementations.

There are no interesting attributes or methods as yet.


Return the number of test runs this repository has stored.

Return count:The count of test runs stored in the repository.

Return the list of run_ids for a given metadata string.

Param:metadata: the metadata string to search for.
Returns:a list of any test_ids that have that metadata value.

Get a TestRun that contains all of and only current failing tests.

Returns:a TestRun.
get_inserter(partial=False, run_id=None, metadata=None)[source]

Get an inserter that will insert a test run into the repository.

Repository implementations should implement _get_inserter.

get_inserter() does not add timing data to streams: it should be provided by the caller of get_inserter (e.g. commands.load).

Parameters:partial – DEPREACTED: If True, the stream being inserted only executed some tests rather than all the projects tests. This option is deprecated and no longer does anything. It will be removed in the future.
Return an inserter:
 Inserters meet the extended TestResult protocol that testtools 0.9.2 and above offer. The startTestRun and stopTestRun methods in particular must be called.

Return the latest run.

Equivalent to get_test_run(latest_id()).


Get a list of test ids in the repository

Returns:a list of test ids

Return the test ids from the specified run.

Parameters:run_id – the id of the test run to query.
Returns:a list of test ids for the tests that were part of the specified test run.

Retrieve a TestRun object for run_id.

Parameters:run_id – The test run id to retrieve.
Returns:A TestRun object.

Retrieve estimated times for the tests test_ids.

Parameters:test_ids – The test ids to query for timing data.
Returns:A dict with two keys: ‘known’ and ‘unknown’. The unknown key contains a set with the test ids that did run. The known key contains a dict mapping test ids to time in seconds.

Return the run id for the most recently inserted test run.


Remove a run from the repository

class stestr.repository.abstract.AbstractRepositoryFactory[source]

Interface for making or opening repositories.


Create a repository at URL.

Call on the class of the repository you wish to create.


Open the repository at url.

Raise RepositoryNotFound if there is no repository at the given url.

class stestr.repository.abstract.AbstractTestRun[source]

A test run that has been stored in a repository.

Should implement the StreamResult protocol as well as the stestr specific methods documented here.


Get the id of the test run.

Sometimes test runs will not have an id, e.g. test runs for ‘failing’. In that case, this should return None.


Get the metadata value for the test run.

Returns:A string of the metadata or None if it doesn’t exist.

Get a subunit stream for this test run.


Get a testtools.TestCase-like object that can be run.

Returns:A TestCase like object which can be run to get the individual tests reported to a testtools.StreamResult/TestResult. (Clients of repository should provide an ExtendedToStreamDecorator decorator to permit either API to be used).
exception stestr.repository.abstract.RepositoryNotFound(url)[source]

Raised when we try to open a repository that isn’t there.