code: def test_scalar(self):
      users = self.tables.users
      canary = Mock()
  
      class User(ComparableEntity):
          @validates("name")
          def validate_name(self, key, name):
              canary(key, name)
              ne_(name, "fred")
              return name + " modified"
  
      self.mapper_registry.map_imperatively(User, users)
      sess = fixture_session()
      u1 = User(name="ed")
      eq_(u1.name, "ed modified")
      assert_raises(AssertionError, setattr, u1, "name", "fred")
      eq_(u1.name, "ed modified")
      eq_(canary.mock_calls, [call("name", "ed"), call("name", "fred")])
  
      sess.add(u1)
      sess.commit()
  
      eq_(
          sess.query(User).filter_by(name="ed modified").one(),
          User(name="ed"),
      )
  
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 1 for calling the ValidatorTest obj's underlying member method code with example usage: obj.test_scalar() and returns: unknown