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

Add pytest marker(s) for regridding (to include/exclude) tests #182

Closed
agstephens opened this issue Jul 23, 2021 · 2 comments · Fixed by #243
Closed

Add pytest marker(s) for regridding (to include/exclude) tests #182

agstephens opened this issue Jul 23, 2021 · 2 comments · Fixed by #243
Assignees

Comments

@agstephens
Copy link
Collaborator

agstephens commented Jul 23, 2021

  • clisops version: *
  • Python version: *
  • Operating System: *

Description

Could use pytest markers for dealing with tests that use xesmf. Maybe it would look like:

This approach would avoid needing to individually add decorators...but, running locally would require remembering whether to run with the tag, or not...???

@agstephens agstephens self-assigned this Jul 23, 2021
@sol1105
Copy link
Contributor

sol1105 commented Aug 17, 2022

@agstephens Is this still relevant?

At the moment we use in the module

# Try importing xesmf and set to None if not found at correct version
# If set to None, the `require_module` decorator will throw an exception
XESMF_MINIMUM_VERSION = "0.6.2"
try:
    import xesmf as xe

    if parse_version(xe.__version__) < parse_version(XESMF_MINIMUM_VERSION):
        raise ValueError()
except Exception:
    xe = None

and in the tests

from clisops.core.regrid import XESMF_MINIMUM_VERSION, xe

XESMF_IMPORT_MSG = (
    f"xESMF >= {XESMF_MINIMUM_VERSION} is needed for regridding functionalities."
)


@pytest.mark.skipif(xe is None, reason=XESMF_IMPORT_MSG)
def test123():
  [...]

@agstephens
Copy link
Collaborator Author

Hi @sol1105 , I will close this. Thanks

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

Successfully merging a pull request may close this issue.

2 participants