TestRunnerBase#
- class astropy.tests.runner.TestRunnerBase(*args, **kwargs)[source]#
Bases:
object
The base class for the TestRunner.
A test runner can be constructed by creating a subclass of this class and defining ‘keyword’ methods. These are methods that have the
keyword
decorator, these methods are used to construct allowed keyword arguments to therun_tests
method as a way to allow customization of individual keyword arguments (and associated logic) without having to re-implement the wholerun_tests
method.Examples
A simple keyword method:
class MyRunner(TestRunnerBase): @keyword('default_value'): def spam(self, spam, kwargs): """ spam : `str` The parameter description for the run_tests docstring. """ # Return value must be a list with a CLI parameter for pytest. return ['--spam={}'.format(spam)]
Attributes Summary
Methods Summary
make_test_runner_in
(path)Constructs a
TestRunner
to run in the given path, and returns atest()
function which takes the same arguments asrun_tests
.run_tests
(**kwargs)Attributes Documentation
- RUN_TESTS_DOCSTRING = '\n Run the tests for the package.\n\n This method builds arguments for and then calls ``pytest.main``.\n\n Parameters\n ----------\n{keywords}\n\n '#
Methods Documentation
- classmethod make_test_runner_in(path)[source]#
Constructs a
TestRunner
to run in the given path, and returns atest()
function which takes the same arguments asrun_tests
.The returned
test()
function will be defined in the module this was called from. This is used to implement theastropy.test()
function (or the equivalent for affiliated packages).