From c7111227974826b9a61a44502ecb2464c914402f Mon Sep 17 00:00:00 2001 From: Martin Yeo <40734014+trexfeathers@users.noreply.github.com> Date: Mon, 4 Aug 2025 16:38:11 +0100 Subject: [PATCH 1/3] Add note about removing the iris.tests import. --- docs/src/developers_guide/contributing_pytest_conversions.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/src/developers_guide/contributing_pytest_conversions.rst b/docs/src/developers_guide/contributing_pytest_conversions.rst index 617955c5a1..e24be91410 100644 --- a/docs/src/developers_guide/contributing_pytest_conversions.rst +++ b/docs/src/developers_guide/contributing_pytest_conversions.rst @@ -50,6 +50,10 @@ Conversion Checklist #. Check for references to ``self.tmp_dir``. In pytest, ``tmp_path`` is used instead, and can be passed into functions as a fixture. #. Check for ``if __name__ == 'main'``. This is no longer needed with pytest. +#. Remove the top-level import of :mod:`iris.tests` (usually ``import iris.tests as tests``). + Having followed the above steps, any remaining calls + (e.g. :func:`iris.tests.get_data_path`) should be easily replacable with calls to + :mod:`iris.tests._shared_utils` (e.g. :func:`iris.tests._shared_utils.get_data_path`). #. Check for ``mock.patch("warnings.warn")``. This can be replaced with ``pytest.warns(match=message)``. #. Ensure that all test classes start with ``Test``. Tests will not run in pytest without it. From 7a64ea8ee67cc73aee2698f16579b180fc580184 Mon Sep 17 00:00:00 2001 From: Martin Yeo <40734014+trexfeathers@users.noreply.github.com> Date: Tue, 5 Aug 2025 11:37:57 +0100 Subject: [PATCH 2/3] Split bullet point into two. --- .../developers_guide/contributing_pytest_conversions.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/src/developers_guide/contributing_pytest_conversions.rst b/docs/src/developers_guide/contributing_pytest_conversions.rst index e24be91410..a2717a48b2 100644 --- a/docs/src/developers_guide/contributing_pytest_conversions.rst +++ b/docs/src/developers_guide/contributing_pytest_conversions.rst @@ -50,10 +50,10 @@ Conversion Checklist #. Check for references to ``self.tmp_dir``. In pytest, ``tmp_path`` is used instead, and can be passed into functions as a fixture. #. Check for ``if __name__ == 'main'``. This is no longer needed with pytest. +# Replace any remaining references to :mod:`iris.tests` with references to + :mod:`iris.tests._shared_utils`. (E.g. :func:`iris.tests.get_data_path` to + :func:`iris.tests._shared_utils.get_data_path`). #. Remove the top-level import of :mod:`iris.tests` (usually ``import iris.tests as tests``). - Having followed the above steps, any remaining calls - (e.g. :func:`iris.tests.get_data_path`) should be easily replacable with calls to - :mod:`iris.tests._shared_utils` (e.g. :func:`iris.tests._shared_utils.get_data_path`). #. Check for ``mock.patch("warnings.warn")``. This can be replaced with ``pytest.warns(match=message)``. #. Ensure that all test classes start with ``Test``. Tests will not run in pytest without it. From ac324f2a5e78a7a202f1e01b4dce41071fe5bb19 Mon Sep 17 00:00:00 2001 From: Martin Yeo <40734014+trexfeathers@users.noreply.github.com> Date: Tue, 5 Aug 2025 11:53:51 +0100 Subject: [PATCH 3/3] Fix list. --- docs/src/developers_guide/contributing_pytest_conversions.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/developers_guide/contributing_pytest_conversions.rst b/docs/src/developers_guide/contributing_pytest_conversions.rst index a2717a48b2..a270ac1011 100644 --- a/docs/src/developers_guide/contributing_pytest_conversions.rst +++ b/docs/src/developers_guide/contributing_pytest_conversions.rst @@ -50,7 +50,7 @@ Conversion Checklist #. Check for references to ``self.tmp_dir``. In pytest, ``tmp_path`` is used instead, and can be passed into functions as a fixture. #. Check for ``if __name__ == 'main'``. This is no longer needed with pytest. -# Replace any remaining references to :mod:`iris.tests` with references to +#. Replace any remaining references to :mod:`iris.tests` with references to :mod:`iris.tests._shared_utils`. (E.g. :func:`iris.tests.get_data_path` to :func:`iris.tests._shared_utils.get_data_path`). #. Remove the top-level import of :mod:`iris.tests` (usually ``import iris.tests as tests``).