def test_cant_change_computed_warning(self, test_case): arg_before, arg_after = testing.resolve_lambda(test_case, **locals()) m1 = MetaData() m2 = MetaData() arg_before = [] if arg_before is None else [arg_before] arg_after = [] if arg_after is None else [arg_after] Table( "user", m1, Column("id", Integer, primary_key=True), Column("bar", Integer), Column("foo", Integer, *arg_before), ) Table( "user", m2, Column("id", Integer, primary_key=True), Column("bar", Integer), Column("foo", Integer, *arg_after), ) with mock.patch("alembic.util.warn") as mock_warn: diffs = self._fixture(m1, m2) eq_( mock_warn.mock_calls, [mock.call("Computed default on user.foo cannot be modified")], ) eq_(list(diffs), [])
def test_computed_unchanged(self, test_case): arg_before, arg_after = testing.resolve_lambda(test_case, **locals()) m1 = MetaData() m2 = MetaData() arg_before = [] if arg_before is None else [arg_before] arg_after = [] if arg_after is None else [arg_after] Table( "user", m1, Column("id", Integer, primary_key=True), Column("bar", Integer), Column("foo", Integer, *arg_before), ) Table( "user", m2, Column("id", Integer, primary_key=True), Column("bar", Integer), Column("foo", Integer, *arg_after), ) diffs = self._fixture(m1, m2) eq_(len(diffs), 0)