skbase.testing.QuickTester#

class skbase.testing.QuickTester[source]#

Mixin class which adds the run_tests method to run tests on one object.

Methods

run_tests(obj[, raise_exceptions, ...])

Run all tests on one single object.

run_tests(obj, raise_exceptions=False, tests_to_run=None, fixtures_to_run=None, tests_to_exclude=None, fixtures_to_exclude=None)[source]#

Run all tests on one single object.

All tests in self are run on the following object type fixtures:
if est is a class, then object_class = est, and

object_instance loops over est.create_test_instance()

if est is an object, then object_class = est.__class__, and

object_instance = est

This is compatible with pytest.mark.parametrize decoration,

but currently only with multiple single variable annotations.

Parameters:
objobject class or object instance
raise_exceptionsbool, optional, default=False
whether to return exceptions/failures in the results dict, or raise them

if False: returns exceptions in returned results dict if True: raises exceptions as they occur

tests_to_runstr or list of str, names of tests to run. default = all tests

sub-sets tests that are run to the tests given here.

fixtures_to_runstr or list of str, pytest test-fixture combination codes.

which test-fixture combinations to run. Default = run all of them. sub-sets tests and fixtures to run to the list given here. If both tests_to_run and fixtures_to_run are provided, runs the union, i.e., all test-fixture combinations for tests in tests_to_run,

plus all test-fixture combinations in fixtures_to_run.

tests_to_excludestr or list of str, names of tests to exclude. default = None

removes tests that should not be run, after subsetting via tests_to_run.

fixtures_to_excludestr or list of str, fixtures to exclude. default = None

removes test-fixture combinations that should not be run. This is done after subsetting via fixtures_to_run.

Returns:
resultsdict of results of the tests in self

keys are test/fixture strings, identical as in pytest, e.g., test[fixture] entries are the string “PASSED” if the test passed,

or the exception raised if the test did not pass

returned only if all tests pass, or raise_exceptions=False

Raises:
if raise_exception=True, raises any exception produced by the tests directly

Examples

>>> from skbase.tests.mock_package.test_mock_package import CompositionDummy
>>> from skbase.testing.test_all_objects import TestAllObjects
>>> TestAllObjects().run_tests(
...     CompositionDummy,
...     tests_to_run="test_constructor"
... )
{'test_constructor[CompositionDummy]': 'PASSED'}
>>> TestAllObjects().run_tests(
...     CompositionDummy, fixtures_to_run="test_repr[CompositionDummy-1]"
... )
{'test_repr[CompositionDummy-1]': 'PASSED'}