diff --git a/pyproject.toml b/pyproject.toml index 0ce1f150..2c6117dd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -64,7 +64,7 @@ test = [ "mypy", "pytest", "pytest-cov", - "pytest-lazy-fixture", + "pytest-lazy-fixtures", "tox", ] diff --git a/requirements/requirements_dev.txt b/requirements/requirements_dev.txt index 2e40c828..123b1b45 100644 --- a/requirements/requirements_dev.txt +++ b/requirements/requirements_dev.txt @@ -6,9 +6,9 @@ mypy==1.11.2 myst_parser==4.0.0 pre-commit==3.8.0 pygments>=2.7.4 # not directly required, pinned by Snyk to avoid a vulnerability. -pytest==7.4.4 +pytest==8.3.3 pytest-cov==5.0.0 -pytest-lazy-fixture==0.6.3 +pytest-lazy-fixtures==1.1.1 sphinx==7.4.4 sphinx-rtd-theme==2.0.0 -tox==4.18.0 +tox==4.21.2 diff --git a/setup.cfg b/setup.cfg index f0cfc379..1c9be3bf 100644 --- a/setup.cfg +++ b/setup.cfg @@ -68,7 +68,7 @@ test = mypy pytest pytest-cov - pytest-lazy-fixture + pytest-lazy-fixtures tox diff --git a/tests/test_models/test_core.py b/tests/test_models/test_core.py index 92eae695..e486373b 100644 --- a/tests/test_models/test_core.py +++ b/tests/test_models/test_core.py @@ -45,7 +45,7 @@ import packaging import pytest import torch -from pytest_lazyfixture import lazy_fixture +from pytest_lazy_fixtures import lf from urllib3.exceptions import MaxRetryError, NewConnectionError # Needed to avoid connection error when importing lightly. @@ -194,8 +194,8 @@ def test_bilinear_init() -> None: @pytest.mark.parametrize( ("model", "answer"), [ - (lazy_fixture("exp_fcn"), True), - (lazy_fixture("exp_cnn"), True), + (lf("exp_fcn"), True), + (lf("exp_cnn"), True), (resnet18(), False), ], ) @@ -214,9 +214,9 @@ def test_is_minerva_model(model: Module, compile_model: bool, answer: bool) -> N @pytest.mark.parametrize( ("model", "subtype", "answer"), [ - (lazy_fixture("exp_fcn"), MinervaBackbone, True), - (lazy_fixture("exp_cnn"), MinervaSiamese, False), - (lazy_fixture("exp_simconv"), MinervaSiamese, True), + (lf("exp_fcn"), MinervaBackbone, True), + (lf("exp_cnn"), MinervaSiamese, False), + (lf("exp_simconv"), MinervaSiamese, True), (resnet18(), MinervaBackbone, False), ], ) @@ -236,7 +236,7 @@ def test_is_minerva_subtype( @pytest.mark.parametrize( "model", - (lazy_fixture("exp_fcn"), lazy_fixture("exp_cnn"), lazy_fixture("exp_simconv")), + (lf("exp_fcn"), lf("exp_cnn"), lf("exp_simconv")), ) @pytest.mark.parametrize("compile_model", (True, False)) def test_extract_wrapped_model(model, compile_model: bool) -> None: diff --git a/tests/test_transforms.py b/tests/test_transforms.py index 857e305c..10731563 100644 --- a/tests/test_transforms.py +++ b/tests/test_transforms.py @@ -41,7 +41,7 @@ import pytest import torch from numpy.testing import assert_array_equal -from pytest_lazyfixture import lazy_fixture +from pytest_lazy_fixtures import lf from torch import FloatTensor, LongTensor from torchgeo.datasets import RasterDataset from torchvision.transforms import ColorJitter, RandomHorizontalFlip, RandomVerticalFlip @@ -69,7 +69,7 @@ @pytest.mark.parametrize( ["input_mask", "output"], [ - (lazy_fixture("simple_mask"), torch.tensor([[1, 3, 0], [2, 0, 1], [1, 1, 1]])), + (lf("simple_mask"), torch.tensor([[1, 3, 0], [2, 0, 1], [1, 1, 1]])), ( torch.tensor([[5, 3, 5], [4, 5, 1], [1, 3, 1]], dtype=torch.long), torch.tensor([[0, 3, 0], [2, 0, 1], [1, 3, 1]]), @@ -86,9 +86,7 @@ def test_class_transform( assert repr(transform) == f"ClassTransform(transform={example_matrix})" -@pytest.mark.parametrize( - "sample", (42, lazy_fixture("simple_mask"), lazy_fixture("example_matrix")) -) +@pytest.mark.parametrize("sample", (42, lf("simple_mask"), lf("example_matrix"))) def test_pair_create(sample: Any) -> None: transform = PairCreate() @@ -100,7 +98,7 @@ def test_pair_create(sample: Any) -> None: @pytest.mark.parametrize( "mask", ( - lazy_fixture("simple_mask"), + lf("simple_mask"), torch.tensor( [[1023.0, 3.890, 557.0], [478.0, 5.788, 10009.0], [1.0, 10240.857, 1458.7]] ), @@ -256,22 +254,22 @@ def test_dublicator( Normalise, None, 255, - lazy_fixture("simple_rgb_img"), - lazy_fixture("norm_simple_rgb_img"), + lf("simple_rgb_img"), + lf("norm_simple_rgb_img"), ), ( Normalise, ["image"], 255, - lazy_fixture("simple_rgb_img"), - lazy_fixture("norm_simple_rgb_img"), + lf("simple_rgb_img"), + lf("norm_simple_rgb_img"), ), ( RandomHorizontalFlip, ["image", "mask"], 1.0, - lazy_fixture("simple_sample"), - lazy_fixture("flipped_simple_sample"), + lf("simple_sample"), + lf("flipped_simple_sample"), ), ], ) @@ -349,7 +347,7 @@ def test_swap_keys(random_rgbi_tensor, random_tensor_mask) -> None: @pytest.mark.parametrize( "dataset", - [lazy_fixture("default_image_dataset"), lazy_fixture("ssl4eo_s12_dataset")], + [lf("default_image_dataset"), lf("ssl4eo_s12_dataset")], ) def test_auto_norm(dataset: RasterDataset, random_rgbi_tensor): auto_norm = AutoNorm(dataset, 12) diff --git a/tests/test_utils/test_utils.py b/tests/test_utils/test_utils.py index 9512bc53..ad3aaace 100644 --- a/tests/test_utils/test_utils.py +++ b/tests/test_utils/test_utils.py @@ -56,7 +56,7 @@ from internet_sabotage import no_connection from nptyping import Float, NDArray, Shape from numpy.testing import assert_array_equal -from pytest_lazyfixture import lazy_fixture +from pytest_lazy_fixtures import lf from rasterio.crs import CRS from torchgeo.datasets.utils import BoundingBox, stack_samples from torchvision.datasets import FakeData @@ -241,7 +241,7 @@ def test_eliminate_classes( [2, 1, 5, 1, 6, 3, 0, 1, 1, 5, 7], [2, 4, 5, 1, 6, 3, 0, 2, 1, 5, 7], [2, 1, 5, 1, 6, 3, 0, 1, 1, 5, 7], - lazy_fixture("exp_classes"), + lf("exp_classes"), ), ], )