cachai.run_tests
- cachai.run_tests(*test_args, show_details=False)[source]
Run cachai’s test suite using pytest.
- Parameters
- test_args
str Names of the tests to run (e.g.,
'charts','utilities'). If not provided, all available tests will be executed.- show_details
bool, optional Whether to include verbose output (
-v) in pytest execution (default:True).
- test_args
- Returns
intExit code returned by pytest.
Examples
There are two ways to run the cachai tests. It’s recommended to do so from the terminal, as follows:
$ cachai-test================================ test session starts ================================= platform linux -- Python 3.12.3, pytest-8.4.1, pluggy-1.6.0 -- /path_to_interpreter rootdir: /home/user plugins: anyio-4.10.0 collected 57 items path_to_packages/cachai/tests/test_charts.py ........................... [ 47%] path_to_packages/cachai/tests/test_data.py ....... [ 59%] path_to_packages/cachai/tests/test_dependencies.py ..... [ 68%] path_to_packages/cachai/tests/test_gadgets.py ..... [ 77%] path_to_packages/cachai/tests/test_utilities.py ............. [100%] ================================ 57 passed in 11.89s =================================
You can also run a specific test from the list of available tests, and select the verbose option for more details.
$ cachai-test utilities
================================= test session starts ================================== platform linux -- Python 3.12.3, pytest-8.4.1, pluggy-1.6.0 -- /path_to_interpreter cachedir: .pytest_cache rootdir: /home/user plugins: anyio-4.10.0 collected 13 items path_to_packages/cachai/tests/test_utilities.py::test_validate_kwargs PASSED [ 7%] path_to_packages/cachai/tests/test_utilities.py::test_save_func PASSED [ 15%] path_to_packages/cachai/tests/test_utilities.py::test_rgb_hsl_conversions PASSED [ 23%] path_to_packages/cachai/tests/test_utilities.py::test_mod_color PASSED [ 30%] path_to_packages/cachai/tests/test_utilities.py::test_angspace PASSED [ 38%] path_to_packages/cachai/tests/test_utilities.py::test_angdist[pi->pi] PASSED [ 46%] path_to_packages/cachai/tests/test_utilities.py::test_angdist[3pi/2->pi/2] PASSED [ 53%] path_to_packages/cachai/tests/test_utilities.py::test_angdist[2pi->0] PASSED [ 61%] path_to_packages/cachai/tests/test_utilities.py::test_quadratic_bezier PASSED [ 69%] path_to_packages/cachai/tests/test_utilities.py::test_get_bezier_curve PASSED [ 76%] path_to_packages/cachai/tests/test_utilities.py::test_equidistant PASSED [ 84%] path_to_packages/cachai/tests/test_utilities.py::test_map_from_curve PASSED [ 92%] path_to_packages/cachai/tests/test_utilities.py::test_colormapped_patch PASSED [100%] ================================== 13 passed in 1.11s ==================================
The other option is to run the tests in a Python/Jupyter file.
import cachai as ch # Run all tests verbose ch.run_tests(show_details=True)
import cachai as ch # Run specific tests (e.g. charts and data) ch.run_tests('charts','data')