def test_traverse_changed(self): calls = [] op = (lambda dt: calls.append(dt) or str) array = Array(ANY) transformed = array.traverse(op) self.assertIsNot(transformed, array) self.assertEqual(transformed, Array(str)) self.assertEqual(calls, [ ANY, ])
def test_traverse_noop(self): calls = [] op = (lambda dt: calls.append(dt) or dt) array = Array(Union(str, int)) transformed = array.traverse(op) self.assertIs(transformed, array) self.assertCountEqual( calls, [ # Note that it did not recurse into Union(str, int). Union(str, int), ])