code: def test_validator_w_removes(self):
      users, addresses, Address = (
          self.tables.users,
          self.tables.addresses,
          self.classes.Address,
      )
      canary = Mock()
  
      class User(ComparableEntity):
          @validates("name", include_removes=True)
          def validate_name(self, key, item, remove):
              canary(key, item, remove)
              return item
  
          @validates("addresses", include_removes=True)
          def validate_address(self, key, item, remove):
              canary(key, item, remove)
              return item
  
      self.mapper_registry.map_imperatively(
          User, users, properties={"addresses": relationship(Address)}
      )
      self.mapper_registry.map_imperatively(Address, addresses)
  
      u1 = User()
      u1.name = "ed"
      u1.name = "mary"
      del u1.name
      a1, a2, a3 = Address(), Address(), Address()
      u1.addresses.append(a1)
      u1.addresses.remove(a1)
      u1.addresses = [a1, a2]
      u1.addresses = [a2, a3]
  
      eq_(
          canary.mock_calls,
          [
              call("name", "ed", False),
              call("name", "mary", False),
              call("name", "mary", True),
              # append a1
              call("addresses", a1, False),
              # remove a1
              call("addresses", a1, True),
              # set to [a1, a2] - this is two appends
              call("addresses", a1, False),
              call("addresses", a2, False),
              # set to [a2, a3] - this is a remove of a1,
              # append of a3.  the appends are first.
              # in 1.2 due to #3896, we also get 'a2' in the
              # validates as it is part of the set
              call("addresses", a2, False),
              call("addresses", a3, False),
              call("addresses", a1, True),
          ],
      )
  
imports: from unittest.mock import call
  from unittest.mock import Mock
  from sqlalchemy import exc
  from sqlalchemy import testing
  from sqlalchemy.orm import collections
  from sqlalchemy.orm import relationship
  from sqlalchemy.orm import validates
  from sqlalchemy.testing import assert_raises
  from sqlalchemy.testing import assert_raises_message
  from sqlalchemy.testing import eq_
  from sqlalchemy.testing import ne_
  from sqlalchemy.testing.entities import ComparableEntity
  from sqlalchemy.testing.fixtures import fixture_session
  from test.orm import _fixtures
label_desc: Use image node_id 4 for calling the ValidatorTest obj's underlying member method code with example usage: obj.test_validator_w_removes() and returns: item, item