本文整理匯總了Python中pytz.lazy.LazySet方法的典型用法代碼示例。如果您正苦於以下問題:Python lazy.LazySet方法的具體用法?Python lazy.LazySet怎麽用?Python lazy.LazySet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pytz.lazy
的用法示例。
在下文中一共展示了lazy.LazySet方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_method_ops
# 需要導入模塊: from pytz import lazy [as 別名]
# 或者: from pytz.lazy import LazySet [as 別名]
def test_method_ops(self):
ops = [
'difference', 'intersection', 'isdisjoint',
'issubset', 'issuperset', 'symmetric_difference', 'union',
'difference_update', 'intersection_update',
'symmetric_difference_update', 'update']
for op in ops:
if not hasattr(set, op):
continue # Not in this version of Python.
# Make a copy, as some of the ops are mutating.
lazy = LazySet(set(self.base))
base = set(self.base)
self.assertEqual(
getattr(lazy, op)(set([1])),
getattr(base, op)(set([1])), op)
self.assertEqual(lazy, base, op)
示例2: setUp
# 需要導入模塊: from pytz import lazy [as 別名]
# 或者: from pytz.lazy import LazySet [as 別名]
def setUp(self):
self.base = set([3, 2, 1])
self.lazy = LazySet(iter(set(self.base)))
示例3: test_iops
# 需要導入模塊: from pytz import lazy [as 別名]
# 或者: from pytz.lazy import LazySet [as 別名]
def test_iops(self):
try:
iops = [isub, iand, ior, ixor]
except NameError:
return # Don't exist in older Python versions.
for op in iops:
# Mutating operators, so make fresh copies.
lazy = LazySet(self.base)
base = self.base.copy()
op(lazy, set([1]))
op(base, set([1]))
self.assertEqual(lazy, base, str(op))
示例4: test_bool
# 需要導入模塊: from pytz import lazy [as 別名]
# 或者: from pytz.lazy import LazySet [as 別名]
def test_bool(self):
self.assertTrue(bool(self.lazy))
self.assertFalse(bool(LazySet()))
self.assertFalse(bool(LazySet(iter([]))))