testing
- anemoi.utils.testing.url_for_test_data(path: str) str
Generate the URL for the test data based on the given path.
- anemoi.utils.testing.packages_installed(*names: str) bool
Check if all the given packages are installed.
Use this function to check if the required packages are installed before running tests.
>>> @pytest.mark.skipif(not packages_installed("foo", "bar"), reason="Packages 'foo' and 'bar' are not installed") >>> def test_foo_bar() -> None: >>> ...
- anemoi.utils.testing.skip_missing_packages(*names: str) MarkDecorator
Skip a test if any of the specified packages are missing.
- Parameters:
names (str) – The names of the packages to check.
- Returns:
A decorator that skips the test if any of the specified packages are missing.
- Return type:
Callable
- anemoi.utils.testing.skip_if_missing_command(cmd: str) MarkDecorator
Skip a test if the specified command is not available.
- Parameters:
cmd (str) – The name of the command to check.
- Returns:
A decorator that skips the test if the specified command is not available.
- Return type:
Callable
- anemoi.utils.testing.cli_testing(package: str, cmd: str, *args: str) None
Run a CLI command for testing purposes.
- anemoi.utils.testing.run_tests(globals: dict[str, Callable[[], None]]) None
Run all test functions that start with
test_.- Parameters:
globals (dict[str, Callable[[], None]]) – The global namespace containing the test functions.
Example
Call from a test file to run all tests in that file:
if __name__ == "__main__": from anemoi.utils.testing import run_tests run_tests(globals())
Useful for debugging or running tests in an interactive environment.