diff --git a/xarray/tests/test_accessor_dt.py b/xarray/tests/test_accessor_dt.py index fd33f85678e..061898296e6 100644 --- a/xarray/tests/test_accessor_dt.py +++ b/xarray/tests/test_accessor_dt.py @@ -400,14 +400,14 @@ def calendar(request): return request.param -@pytest.fixture() +@pytest.fixture def cftime_date_type(calendar): if calendar == "standard": calendar = "proleptic_gregorian" return _all_cftime_date_types()[calendar] -@pytest.fixture() +@pytest.fixture def times(calendar): import cftime @@ -419,7 +419,7 @@ def times(calendar): ) -@pytest.fixture() +@pytest.fixture def data(times): data = np.random.rand(10, 10, _NT) lons = np.linspace(0, 11, 10) @@ -429,7 +429,7 @@ def data(times): ) -@pytest.fixture() +@pytest.fixture def times_3d(times): lons = np.linspace(0, 11, 10) lats = np.linspace(0, 20, 10) diff --git a/xarray/tests/test_coding_times.py b/xarray/tests/test_coding_times.py index 22cf0edfddd..8a021d4d2d5 100644 --- a/xarray/tests/test_coding_times.py +++ b/xarray/tests/test_coding_times.py @@ -805,7 +805,7 @@ def calendar(request): return request.param -@pytest.fixture() +@pytest.fixture def times(calendar): import cftime @@ -817,7 +817,7 @@ def times(calendar): ) -@pytest.fixture() +@pytest.fixture def data(times): data = np.random.rand(2, 2, 4) lons = np.linspace(0, 11, 2) @@ -827,7 +827,7 @@ def data(times): ) -@pytest.fixture() +@pytest.fixture def times_3d(times): lons = np.linspace(0, 11, 2) lats = np.linspace(0, 20, 2) diff --git a/xarray/tests/test_dask.py b/xarray/tests/test_dask.py index f14bacc1211..50870ca6976 100644 --- a/xarray/tests/test_dask.py +++ b/xarray/tests/test_dask.py @@ -255,14 +255,10 @@ def test_concat(self): def test_missing_methods(self): v = self.lazy_var - try: + with pytest.raises(NotImplementedError, match="dask"): v.argsort() - except NotImplementedError as err: - assert "dask" in str(err) - try: + with pytest.raises(NotImplementedError, match="dask"): v[0].item() - except NotImplementedError as err: - assert "dask" in str(err) def test_univariate_ufunc(self): u = self.eager_var diff --git a/xarray/tests/test_datatree.py b/xarray/tests/test_datatree.py index 23bc194695c..82c624b9bf6 100644 --- a/xarray/tests/test_datatree.py +++ b/xarray/tests/test_datatree.py @@ -2325,7 +2325,7 @@ def close(self): self.closed = True -@pytest.fixture() +@pytest.fixture def tree_and_closers(): tree = DataTree.from_dict({"/child/grandchild": None}) closers = { diff --git a/xarray/tests/test_distributed.py b/xarray/tests/test_distributed.py index 77caf6c6750..6c6071bc0ca 100644 --- a/xarray/tests/test_distributed.py +++ b/xarray/tests/test_distributed.py @@ -220,7 +220,7 @@ def test_dask_distributed_read_netcdf_integration_test( # fixture vendored from dask # heads-up, this is using quite private zarr API # https://github.com/dask/dask/blob/e04734b4d8959ba259801f2e2a490cb4ee8d891f/dask/tests/test_distributed.py#L338-L358 -@pytest.fixture(scope="function") +@pytest.fixture def zarr(client): zarr_lib = pytest.importorskip("zarr") # Zarr-Python 3 lazily allocates a dedicated thread/IO loop diff --git a/xarray/tests/test_formatting_html.py b/xarray/tests/test_formatting_html.py index a17fffc3683..4af9c69a908 100644 --- a/xarray/tests/test_formatting_html.py +++ b/xarray/tests/test_formatting_html.py @@ -231,7 +231,7 @@ def childfree_tree(self, childfree_tree_factory): """ return childfree_tree_factory() - @pytest.fixture(scope="function") + @pytest.fixture def mock_datatree_node_repr(self, monkeypatch): """ Apply mocking for datatree_node_repr. @@ -245,7 +245,7 @@ def mock(group_title, dt): monkeypatch.setattr(fh, "datatree_node_repr", mock) - @pytest.fixture(scope="function") + @pytest.fixture def mock_wrap_datatree_repr(self, monkeypatch): """ Apply mocking for _wrap_datatree_repr. diff --git a/xarray/tests/test_plot.py b/xarray/tests/test_plot.py index bfa87386dbc..4a2c9479b4e 100644 --- a/xarray/tests/test_plot.py +++ b/xarray/tests/test_plot.py @@ -66,7 +66,7 @@ def figure_context(*args, **kwargs): plt.close("all") -@pytest.fixture(scope="function", autouse=True) +@pytest.fixture(autouse=True) def test_all_figures_closed(): """meta-test to ensure all figures are closed at the end of a test