From 865d5796f8eee7b54bd032e8b6fdc092d4fa7808 Mon Sep 17 00:00:00 2001 From: qazal <77887910+Qazalin@users.noreply.github.com> Date: Sat, 4 Oct 2025 12:44:56 +0300 Subject: [PATCH] add a test for untested Tensor.assign behavior (#12448) * add a test for untested Tensor.assign behavior * better --- test/test_assign.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/test_assign.py b/test/test_assign.py index 63b6227b9e..f8ffe3fee7 100644 --- a/test/test_assign.py +++ b/test/test_assign.py @@ -119,6 +119,17 @@ class TestAssign(unittest.TestCase): new = a + old_a np.testing.assert_allclose(new.numpy(), 4) + def test_assign_changes_alt(self, realize=False): + a = Tensor(1).contiguous() + if realize: a.realize() + b = a.contiguous() # b returns a new Tensor + b.assign(2) + b.realize() + self.assertNotEqual(a.item(), b.item()) + # on a realized Tensor contiguous child changes the source + @unittest.expectedFailure + def test_assign_changes_realized_alt(self): return self.test_assign_changes_alt(realize=True) + def test_assign_diamond_cycle(self): # NOTE: should *not* raise AssertionError from numpy with self.assertRaisesRegex(RuntimeError, "cycle"):