Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a draft style guide for iris pytest #5785

Draft
wants to merge 4 commits into
base: FEATURE_pytest_conversion
Choose a base branch
from

Conversation

ESadek-MO
Copy link
Contributor

🚀 Pull Request

This is a style guide to offer some consistency on iris' approach to testing.

Formatting and phrasing is not final, at the moment stands as a PoC.

Copy link

codecov bot commented Feb 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.74%. Comparing base (e509f14) to head (9a4a45b).
Report is 119 commits behind head on FEATURE_pytest_conversion.

❗ Current head 9a4a45b differs from pull request most recent head 37a342f. Consider uploading reports for the commit 37a342f to get more accurate results

Additional details and impacted files
@@                      Coverage Diff                      @@
##           FEATURE_pytest_conversion    #5785      +/-   ##
=============================================================
+ Coverage                      89.71%   89.74%   +0.03%     
=============================================================
  Files                             90       92       +2     
  Lines                          22816    22940     +124     
  Branches                        5438     5462      +24     
=============================================================
+ Hits                           20469    20588     +119     
- Misses                          1617     1620       +3     
- Partials                         730      732       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@trexfeathers trexfeathers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @ESadek-MO!

You've definitely captured everything the team discussed offline, and the spirit of compromise is much more realistic than many style guides I've read in the past 💐

Some changes below

docs/src/developers_guide/testing_style_guide.rst Outdated Show resolved Hide resolved
docs/src/developers_guide/testing_style_guide.rst Outdated Show resolved Hide resolved
docs/src/developers_guide/testing_style_guide.rst Outdated Show resolved Hide resolved
docs/src/developers_guide/testing_style_guide.rst Outdated Show resolved Hide resolved
docs/src/developers_guide/testing_style_guide.rst Outdated Show resolved Hide resolved
docs/src/developers_guide/testing_style_guide.rst Outdated Show resolved Hide resolved
@pp-mo pp-mo mentioned this pull request Mar 12, 2024
@ESadek-MO ESadek-MO changed the base branch from main to FEATURE_pytest_conversion March 27, 2024 14:26
Comment on lines +228 to +230
=============
Testing tools
=============
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This heading has not rendered at the correct level

-------------

As a package capable of generating graphical outputs, Iris has utilities for
creating and updating graphical tests - see :ref:`testing.graphics` for more
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've read through that dedicated page and I don't believe anything needs changing 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can confirm that this is a faithful lift-and-shift from all the 'sub-pages'. The sequence makes sense to me.

Happy to delete those now?

Comment on lines +277 to +278
Context managers
----------------
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This heading needs to be a higher level

Comment on lines +167 to +168
Directory
---------
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section overlaps significantly with:

Test Categories
===============

After the change from ``unittest`` to ``pytest``, ``IrisTest.patch`` has been
converted into :meth:`~iris.tests._shared_utils.patch`.

This is currently not implemented, and will raise an error if called.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we have discovered the mock.patch pattern is the perfect replacement for this?

Comment on lines +285 to +286
:meth:`~iris.tests.IrisTest_nometa.assert_no_warnings_regexp` and
:meth:`~iris.tests.IrisTest_nometa.assert_logs`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs changing to reference _shared_utils

Comment on lines +252 to +253
assertions, such as :meth:`~iris.tests._shared_utils.assert_array_equal`, and
:meth:`~iris.tests._shared_utils.assert_array_almost_equal`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are now :func: rather than :meth:

Comment on lines +262 to +265
:meth:`~iris.tests._shared_utils.assert_CML_approx_data`
:meth:`~iris.tests._shared_utils.assert_CDL`
:meth:`~iris.tests._shared_utils.assert_CML` and
:meth:`~iris.tests._shared_utils.assert_text_file`. See docstrings for more
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:func:


All functions listed on this page are defined within
:mod:`iris.tests._shared_utils`. They can be accessed within a test using
``_shared_utils.exampleFunction``.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably best to use the non-unittest format e.g. example_function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

None yet

2 participants