Skip to content

Commit

Permalink
Adjust test to find xclim location via importlib (#2028)
Browse files Browse the repository at this point in the history
### What kind of change does this PR introduce?

* The `TestOfficialYaml` test now uses a dynamic method for locating the
installed location of `xclim`.

### Does this PR introduce a breaking change?

No.

### Other information:

When xclim is installed, there is no guarantee that `src` will be the
top-level folder. This is by design to ensure that we don't write tests
that try to navigate the folder-tree of `xclim` using relative paths
from the `tests` folder. Seeing as this is the only failing test on
`conda-forge`, I think we're doing an OK job.

Commit that bypasses this problem on conda-forge:
conda-forge/xclim-feedstock@f1886ee
  • Loading branch information
Zeitsperre authored Jan 15, 2025
2 parents e34df04 + 1456e8b commit 9cce44b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ New features and enhancements
Internal changes
^^^^^^^^^^^^^^^^
* `sphinx-codeautolink` and `pygments` have been temporarily pinned due to breaking API changes. (:pull:`2030`).
* Adjusted the ``TestOfficialYaml`` test to use a dynamic method for finding the installed location of `xclim`. (:pull:`2028`).

v0.54.0 (2024-12-16)
--------------------
Expand Down
3 changes: 2 additions & 1 deletion tests/test_modules.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

from importlib.util import find_spec
from inspect import _empty # noqa
from pathlib import Path

Expand Down Expand Up @@ -264,7 +265,7 @@ def test_validate(tmp_path):


class TestOfficialYaml(yamale.YamaleTestCase):
base_dir = str(Path(__file__).parent.parent / "src" / "xclim" / "data")
base_dir = str(Path(find_spec("xclim").origin).parent.joinpath("data"))
schema = "schema.yml"
yaml = ["cf.yml", "anuclim.yml", "icclim.yml"]

Expand Down

0 comments on commit 9cce44b

Please sign in to comment.