diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 54efc0c3..fad67bb8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -189,7 +189,7 @@ jobs: python -m pip check || true - name: Test RavenPy run: | - python -m pytest --cov=ravenpy --numprocesses=logical + python -m pytest --numprocesses=logical --cov=src/ravenpy --cov-report=lcov - name: Report Coverage uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2.3.6 with: diff --git a/.gitignore b/.gitignore index a8f33d97..35effac7 100644 --- a/.gitignore +++ b/.gitignore @@ -47,6 +47,7 @@ htmlcov/ .coverage.* .cache nosetests.xml +coverage.lcov coverage.xml *.cover .hypothesis/ diff --git a/pyproject.toml b/pyproject.toml index e7b515de..57920946 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -205,9 +205,13 @@ values = [ [tool.codespell] ignore-words-list = "astroid,documen,socio-economic" +[tool.coverage.paths] +source = ["src/ravenpy/", "*/site-packages/ravenpy/"] + [tool.coverage.run] relative_files = true omit = ["tests/*.py"] +source = ["ravenpy"] [tool.flit.sdist] include = [ @@ -319,9 +323,11 @@ warn_required_dynamic_aliases = true warn_untyped_fields = true [tool.pytest.ini_options] +minversion = "7.0" addopts = [ "--verbose", "--color=yes", + "--strict-config", "--strict-markers", "--tb=native", "--numprocesses=0", @@ -329,9 +335,14 @@ addopts = [ "--dist=worksteal" ] python_files = "test_*.py" -norecursedirs = ["src", ".git", "bin"] +norecursedirs = ["docs/notebooks"] filterwarnings = ["ignore::UserWarning"] -testpaths = "tests" +testpaths = [ + "tests" +] +pythonpath = [ + "src" +] markers = [ "slow: marks tests as slow (deselect with '-m \"not slow\"')", "online: mark tests that require external services (deselect with '-m \"not online\"')" diff --git a/tests/test_commands.py b/tests/test_commands.py index 20971f2a..887bfa63 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -1,6 +1,5 @@ import re from collections.abc import Sequence -from shutil import copyfile from textwrap import dedent from typing import Union diff --git a/tests/test_coords.py b/tests/test_coords.py index b3bd7033..0c14e0d2 100644 --- a/tests/test_coords.py +++ b/tests/test_coords.py @@ -1,5 +1,3 @@ -import xarray as xr - from ravenpy.utilities.coords import infer_scale_and_offset from ravenpy.utilities.testdata import open_dataset diff --git a/tests/test_geoserver.py b/tests/test_geoserver.py index b02f2da8..a6eb70c0 100644 --- a/tests/test_geoserver.py +++ b/tests/test_geoserver.py @@ -1,16 +1,14 @@ import os import sys import tempfile -import urllib.request import numpy as np import pytest -pytestmark = pytest.mark.online - # FIXME: Remove XFAIL marks once OWSLib > 0.24.1 is released. +@pytest.mark.online class TestHydroBASINS: geoserver = pytest.importorskip("ravenpy.utilities.geoserver") @@ -23,13 +21,10 @@ def test_select_hybas_na_domain_bbox(self): dom = self.geoserver.select_hybas_domain(bbox=bbox) assert dom == "na" - -if os.getenv("CONDA_DEFAULT_ENV") == "raven-dev": - # FIXME: Investigate why this fails for macOS on PyPI. - @pytest.mark.skip( - sys.platform == "darwin" and not os.getenv("CONDA_PREFIX"), - reason="Fails on MacOS w/ PyPI", - ) + # @pytest.mark.skip( + # sys.platform == "darwin" and not os.getenv("CONDA_PREFIX"), + # reason="Fails on MacOS w/ PyPI", + # ) def test_select_hybas_ar_domain_point(self): point = -114.65, 61.35 dom = self.geoserver.select_hybas_domain(point=point) @@ -90,6 +85,7 @@ def test_hydrobasins_upstream_aggregate(self, tmp_path): ) +@pytest.mark.online class TestHydroRouting: geoserver = pytest.importorskip("ravenpy.utilities.geoserver") @@ -135,6 +131,7 @@ def test_hydro_routing_upstream(self, tmp_path): assert len(gdf_upstream) == 33 # TODO: Verify this with the model maintainers. +@pytest.mark.online class TestWFS: geoserver = pytest.importorskip("ravenpy.utilities.geoserver") @@ -174,6 +171,7 @@ def test_get_feature_attributes_wfs(self): assert gdf.STATE_NAME.unique() == "Nevada" +@pytest.mark.online class TestWCS: io = pytest.importorskip("ravenpy.utilities.io") geoserver = pytest.importorskip("ravenpy.utilities.geoserver") diff --git a/tests/test_parsers.py b/tests/test_parsers.py deleted file mode 100644 index d0fd308d..00000000 --- a/tests/test_parsers.py +++ /dev/null @@ -1,2 +0,0 @@ -def test_parse_outputs(): - pass