Skip to content

Commit

Permalink
Skip tests that require optional deps
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjstewart committed Sep 30, 2023
1 parent e3b3544 commit da9783f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/datasets/test_advance.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def test_mock_missing_module(
dataset[0]

def test_plot(self, dataset: ADVANCE) -> None:
pytest.importorskip("scipy", minversion="1.6.2")
x = dataset[0].copy()
dataset.plot(x, suptitle="Test")
plt.close()
Expand Down
3 changes: 3 additions & 0 deletions tests/datasets/test_skippd.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
from torchgeo.datasets import SKIPPD


pytest.importorskip("h5py", minversion="3")


def download_url(url: str, root: str, *args: str, **kwargs: str) -> None:
shutil.copy(url, root)

Expand Down
4 changes: 4 additions & 0 deletions tests/trainers/test_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
from torchgeo.trainers import ObjectDetectionTask


# MAP metric requires pycocotools to be installed
pytest.importorskip("pycocotools")


class PredictObjectDetectionDataModule(NASAMarineDebrisDataModule):
def setup(self, stage: str) -> None:
self.predict_dataset = NASAMarineDebris(**self.kwargs)
Expand Down
3 changes: 3 additions & 0 deletions tests/trainers/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ def create_model(*args: Any, **kwargs: Any) -> Module:
def test_trainer(
self, monkeypatch: MonkeyPatch, name: str, fast_dev_run: bool
) -> None:
if name == "skippd":
pytest.importorskip("h5py", minversion="3")

config = os.path.join("tests", "conf", name + ".yaml")

monkeypatch.setattr(timm, "create_model", self.create_model)
Expand Down

0 comments on commit da9783f

Please sign in to comment.