Skip to content

Commit 476e017

Browse files
committed
use delayed_given in the existing tests
1 parent dfc9634 commit 476e017

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

xarray_array_testing/creation.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
import hypothesis.strategies as st
1+
from functools import partial
2+
23
import xarray.testing.strategies as xrst
3-
from hypothesis import given
44

55
from xarray_array_testing.base import DuckArrayTestMixin
6+
from xarray_array_testing.decorator import delayed_given
67

78

89
class CreationTests(DuckArrayTestMixin):
9-
@given(st.data())
10-
def test_create_variable(self, data):
11-
variable = data.draw(xrst.variables(array_strategy_fn=self.array_strategy_fn))
12-
10+
@delayed_given(partial(xrst.variables))
11+
def test_create_variable(self, variable):
1312
assert isinstance(variable.data, self.array_type)

xarray_array_testing/reduction.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from contextlib import nullcontext
2+
from functools import partial
23

3-
import hypothesis.strategies as st
44
import pytest
55
import xarray.testing.strategies as xrst
6-
from hypothesis import given
76

87
from xarray_array_testing.base import DuckArrayTestMixin
8+
from xarray_array_testing.decorator import delayed_given
99

1010

1111
class ReductionTests(DuckArrayTestMixin):
@@ -14,10 +14,8 @@ def expected_errors(op, **parameters):
1414
return nullcontext()
1515

1616
@pytest.mark.parametrize("op", ["mean", "sum", "prod", "std", "var"])
17-
@given(st.data())
18-
def test_variable_mean(self, op, data):
19-
variable = data.draw(xrst.variables(array_strategy_fn=self.array_strategy_fn))
20-
17+
@delayed_given(partial(xrst.variables))
18+
def test_variable(self, op, variable):
2119
with self.expected_errors(op, variable=variable):
2220
# compute using xr.Variable.<OP>()
2321
actual = getattr(variable, op)().data

0 commit comments

Comments
 (0)