TestRunnerBase

class astropy.tests.runner.TestRunnerBase(base_path)[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 the run_tests method as a way to allow customization of individual keyword arguments (and associated logic) without having to re-implement the whole run_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

RUN_TESTS_DOCSTRING

Methods Summary

make_test_runner_in(path) Constructs a TestRunner to run in the given path, and returns a test() function which takes the same arguments as TestRunner.run_tests.
run_tests(self, \*\*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 a test() function which takes the same arguments as TestRunner.run_tests.

The returned test() function will be defined in the module this was called from. This is used to implement the astropy.test() function (or the equivalent for affiliated packages).

run_tests(self, **kwargs)[source]