本文整理汇总了Python中celery.local.Proxy.__int__方法的典型用法代码示例。如果您正苦于以下问题:Python Proxy.__int__方法的具体用法?Python Proxy.__int__怎么用?Python Proxy.__int__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类celery.local.Proxy
的用法示例。
在下文中一共展示了Proxy.__int__方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_int
# 需要导入模块: from celery.local import Proxy [as 别名]
# 或者: from celery.local.Proxy import __int__ [as 别名]
def test_int(self):
self.assertEqual(Proxy(lambda: 10) + 1, Proxy(lambda: 11))
self.assertEqual(Proxy(lambda: 10) - 1, Proxy(lambda: 9))
self.assertEqual(Proxy(lambda: 10) * 2, Proxy(lambda: 20))
self.assertEqual(Proxy(lambda: 10) ** 2, Proxy(lambda: 100))
self.assertEqual(Proxy(lambda: 20) / 2, Proxy(lambda: 10))
self.assertEqual(Proxy(lambda: 20) // 2, Proxy(lambda: 10))
self.assertEqual(Proxy(lambda: 11) % 2, Proxy(lambda: 1))
self.assertEqual(Proxy(lambda: 10) << 2, Proxy(lambda: 40))
self.assertEqual(Proxy(lambda: 10) >> 2, Proxy(lambda: 2))
self.assertEqual(Proxy(lambda: 10) ^ 7, Proxy(lambda: 13))
self.assertEqual(Proxy(lambda: 10) | 40, Proxy(lambda: 42))
self.assertEqual(~Proxy(lambda: 10), Proxy(lambda: -11))
self.assertEqual(-Proxy(lambda: 10), Proxy(lambda: -10))
self.assertEqual(+Proxy(lambda: -10), Proxy(lambda: -10))
self.assertTrue(Proxy(lambda: 10) < Proxy(lambda: 20))
self.assertTrue(Proxy(lambda: 20) > Proxy(lambda: 10))
self.assertTrue(Proxy(lambda: 10) >= Proxy(lambda: 10))
self.assertTrue(Proxy(lambda: 10) <= Proxy(lambda: 10))
self.assertTrue(Proxy(lambda: 10) == Proxy(lambda: 10))
self.assertTrue(Proxy(lambda: 20) != Proxy(lambda: 10))
x = Proxy(lambda: 10)
x -= 1
self.assertEqual(x, 9)
x = Proxy(lambda: 9)
x += 1
self.assertEqual(x, 10)
x = Proxy(lambda: 10)
x *= 2
self.assertEqual(x, 20)
x = Proxy(lambda: 20)
x /= 2
self.assertEqual(x, 10)
x = Proxy(lambda: 10)
x %= 2
self.assertEqual(x, 0)
x = Proxy(lambda: 10)
x <<= 3
self.assertEqual(x, 80)
x = Proxy(lambda: 80)
x >>= 4
self.assertEqual(x, 5)
x = Proxy(lambda: 5)
x ^= 1
self.assertEqual(x, 4)
x = Proxy(lambda: 4)
x **= 4
self.assertEqual(x, 256)
x = Proxy(lambda: 256)
x //= 2
self.assertEqual(x, 128)
x = Proxy(lambda: 128)
x |= 2
self.assertEqual(x, 130)
x = Proxy(lambda: 130)
x &= 10
self.assertEqual(x, 2)
x = Proxy(lambda: 10)
self.assertEqual(type(x.__float__()), float)
self.assertEqual(type(x.__int__()), int)
self.assertEqual(type(x.__long__()), long)
self.assertTrue(hex(x))
self.assertTrue(oct(x))
示例2: test_int
# 需要导入模块: from celery.local import Proxy [as 别名]
# 或者: from celery.local.Proxy import __int__ [as 别名]
def test_int(self):
assert Proxy(lambda: 10) + 1 == Proxy(lambda: 11)
assert Proxy(lambda: 10) - 1 == Proxy(lambda: 9)
assert Proxy(lambda: 10) * 2 == Proxy(lambda: 20)
assert Proxy(lambda: 10) ** 2 == Proxy(lambda: 100)
assert Proxy(lambda: 20) / 2 == Proxy(lambda: 10)
assert Proxy(lambda: 20) // 2 == Proxy(lambda: 10)
assert Proxy(lambda: 11) % 2 == Proxy(lambda: 1)
assert Proxy(lambda: 10) << 2 == Proxy(lambda: 40)
assert Proxy(lambda: 10) >> 2 == Proxy(lambda: 2)
assert Proxy(lambda: 10) ^ 7 == Proxy(lambda: 13)
assert Proxy(lambda: 10) | 40 == Proxy(lambda: 42)
assert Proxy(lambda: 10) != Proxy(lambda: -11)
assert Proxy(lambda: 10) != Proxy(lambda: -10)
assert Proxy(lambda: -10) == Proxy(lambda: -10)
assert Proxy(lambda: 10) < Proxy(lambda: 20)
assert Proxy(lambda: 20) > Proxy(lambda: 10)
assert Proxy(lambda: 10) >= Proxy(lambda: 10)
assert Proxy(lambda: 10) <= Proxy(lambda: 10)
assert Proxy(lambda: 10) == Proxy(lambda: 10)
assert Proxy(lambda: 20) != Proxy(lambda: 10)
assert Proxy(lambda: 100).__divmod__(30)
assert Proxy(lambda: 100).__truediv__(30)
assert abs(Proxy(lambda: -100))
x = Proxy(lambda: 10)
x -= 1
assert x == 9
x = Proxy(lambda: 9)
x += 1
assert x == 10
x = Proxy(lambda: 10)
x *= 2
assert x == 20
x = Proxy(lambda: 20)
x /= 2
assert x == 10
x = Proxy(lambda: 10)
x %= 2
assert x == 0
x = Proxy(lambda: 10)
x <<= 3
assert x == 80
x = Proxy(lambda: 80)
x >>= 4
assert x == 5
x = Proxy(lambda: 5)
x ^= 1
assert x == 4
x = Proxy(lambda: 4)
x **= 4
assert x == 256
x = Proxy(lambda: 256)
x //= 2
assert x == 128
x = Proxy(lambda: 128)
x |= 2
assert x == 130
x = Proxy(lambda: 130)
x &= 10
assert x == 2
x = Proxy(lambda: 10)
assert type(x.__float__()) == float
assert type(x.__int__()) == int
if not PY3:
assert type(x.__long__()) == long_t
assert hex(x)
assert oct(x)