Skip to content

Commit fd984dc

Browse files
committed
TST: Add test to lazy_xp_function works for class methods
1 parent 7f3320f commit fd984dc

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

tests/test_testing.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,19 @@ def f(self, y: Array) -> Array:
350350
lazy_xp_function((B, "g"))
351351

352352

353-
def test_lazy_xp_function_class_inheritance():
354-
assert hasattr(B.g, "_lazy_xp_function")
355-
assert not hasattr(A.g, "_lazy_xp_function")
353+
class TestLazyXpFunctionClasses:
354+
def test_parent_method_not_tagged(self):
355+
assert hasattr(B.g, "_lazy_xp_function")
356+
assert not hasattr(A.g, "_lazy_xp_function")
357+
358+
def test_lazy_xp_function_classes(self, xp):
359+
x = xp.asarray([1.1, 2.2, 3.3])
360+
y = xp.asarray([1.0, 2.0, 3.0])
361+
z = xp.asarray([3.0, 4.0, 5.0])
362+
foo = B(x)
363+
observed = foo.g(y, z)
364+
expected = xp.asarray(44.0)[()]
365+
xp_assert_close(observed, expected)
356366

357367

358368
def dask_raises(x: Array) -> Array:

0 commit comments

Comments
 (0)