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