Пример #1
0
def test_increment(): # type: () -> None
    s = operation.Increment(1)
    assert s.amount == 1
    previous = operation.Increment(2)
    new = s._merge(previous)
    assert isinstance(new, operation.Increment)
    assert new.amount == 3
Пример #2
0
    def increment(self, attr, amount=1):
        """
        在对象此字段上自增对应的数值,如果数值没有指定,默认为一。

        :param attr: 字段名
        :param amount: 自增量
        :return: 当前对象
        """
        return self.set(attr, operation.Increment(amount))