|
| 1 | +.. _testing: |
| 2 | + |
| 3 | +Testing |
| 4 | +----------------------- |
| 5 | + |
| 6 | +To run the test suite, you can use the following command: |
| 7 | + |
| 8 | +.. code-block:: shell |
| 9 | +
|
| 10 | + pytest |
| 11 | +
|
| 12 | +
|
| 13 | +Long tests |
| 14 | +~~~~~~~~~~~~~ |
| 15 | + |
| 16 | +Please note that by default all the tests based on remote services e.g. :ref:`data-sources-mars` are skipped. This is done because they can take a very long time to complete or just hang. To enable all these tests you need to run: |
| 17 | + |
| 18 | +.. code-block:: shell |
| 19 | +
|
| 20 | + pytest -E long -v |
| 21 | +
|
| 22 | +If just want to run e.g. the :ref:`data-sources-mars` tests you can use: |
| 23 | + |
| 24 | +.. code-block:: shell |
| 25 | +
|
| 26 | + pytest -E long -v -k mars |
| 27 | +
|
| 28 | +
|
| 29 | +Timeout for CDS tests |
| 30 | +~~~~~~~~~~~~~~~~~~~~~~ |
| 31 | + |
| 32 | +Some :ref:`data-sources-cds` retrieval tests used to hang so an execution timeout was added to all the tests in ``tests/sources/test_cds.py``. The default value is 30 seconds and it can be controlled via the ``--cds-timeout`` custom option to ``pytest``. Please note that some tests have a custom hardcoded timeout value that cannot be changed via this option. |
| 33 | + |
| 34 | +E.g. to set the timeout to 60 seconds for all CDS tests run (supposing their names contain "test_cds"): |
| 35 | + |
| 36 | +.. code-block:: shell |
| 37 | +
|
| 38 | + pytest -E long --cds-timeout=60 -v -k test_cds |
| 39 | +
|
| 40 | +
|
| 41 | +Credentials |
| 42 | +~~~~~~~~~~~~~~~ |
| 43 | + |
| 44 | +Some tests require credentials to access remote services. The existence of credentials are checked and the related tests are skipped accordingly. The logic can be found in ``src/earthkit/data/testing.py``. |
| 45 | + |
| 46 | +FDB tests |
| 47 | +~~~~~~~~~~~~ |
| 48 | + |
| 49 | +The :ref:`data-sources-fdb` tests are only run if ``pyfdb`` can be imported and the ``FDB_HOME`` environment variable is set. See the logic in ``src/earthkit/data/testing.py``. |
| 50 | + |
| 51 | + |
| 52 | +Optional dependencies |
| 53 | +~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 54 | + |
| 55 | +Tests generally require all optional dependencies to be installed. However, the availability of some optional dependencies are checked and the related tests are skipped accordingly. This is typically used for dependencies which are not part of the ``[all]`` install option (see :ref:`install`). The logic can be found in ``src/earthkit/data/testing.py``. |
| 56 | + |
| 57 | + |
| 58 | +no_cache_init tests |
| 59 | +~~~~~~~~~~~~~~~~~~~ |
| 60 | + |
| 61 | +Tests marked with ``pytest.mark.no_cache_init`` use the ``pytest-forked`` plugin to run in a separate process. They must be run as: |
| 62 | + |
| 63 | +.. code-block:: shell |
| 64 | +
|
| 65 | + pytest --forked -v -m no_cache_init |
| 66 | +
|
| 67 | +
|
| 68 | +Notebooks |
| 69 | +~~~~~~~~~~~~~ |
| 70 | + |
| 71 | +The notebook examples from the ``docs/examples`` folder are part of the test suite and are run automatically. However, some notebooks are skipped mainly because they use remote data sources. This is controlled via the ``SKIP`` list in ``tests/documentation/test_notebooks.py``. You can modify this list to add or remove notebooks to be skipped. |
| 72 | + |
| 73 | +To run only the notebooks tests you can use: |
| 74 | + |
| 75 | +.. code-block:: shell |
| 76 | +
|
| 77 | + pytest -v -m notebook |
| 78 | +
|
| 79 | +
|
| 80 | +Documentation code snippets |
| 81 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 82 | + |
| 83 | +All ``.py`` files in the ``docs`` folder can potentially contain example code snippets and are part of the test suite and run automatically. Many of these are actually not examples and skipped. This is controlled via the ``SKIP`` list in ``tests/documentation/test_examples.py``. You can modify this list to add or remove snippets to be skipped. |
0 commit comments