本文整理匯總了Python中sqlalchemy.util.IdentitySet方法的典型用法代碼示例。如果您正苦於以下問題:Python util.IdentitySet方法的具體用法?Python util.IdentitySet怎麽用?Python util.IdentitySet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sqlalchemy.util
的用法示例。
在下文中一共展示了util.IdentitySet方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_dunder_lt
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import IdentitySet [as 別名]
def test_dunder_lt(self):
super_, sub_, twin1, twin2, unique1, unique2 = self._create_sets()
# basic set math
eq_(sub_ < super_, True)
eq_(super_ < sub_, False)
# the same sets
eq_(twin1 < twin2, False)
eq_(twin2 < twin1, False)
# totally different sets
eq_(unique1 < unique2, False)
eq_(unique2 < unique1, False)
# not an IdentitySet
def should_raise():
not_an_identity_set = object()
return unique1 < not_an_identity_set
self._assert_unorderable_types(should_raise)
示例2: test_dunder_ge
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import IdentitySet [as 別名]
def test_dunder_ge(self):
super_, sub_, twin1, twin2, unique1, unique2 = self._create_sets()
# basic set math
eq_(sub_ >= super_, False)
eq_(super_ >= sub_, True)
# the same sets
eq_(twin1 >= twin2, True)
eq_(twin2 >= twin1, True)
# totally different sets
eq_(unique1 >= unique2, False)
eq_(unique2 >= unique1, False)
# not an IdentitySet
def should_raise():
not_an_identity_set = object()
return unique1 >= not_an_identity_set
self._assert_unorderable_types(should_raise)
示例3: test_dunder_gt
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import IdentitySet [as 別名]
def test_dunder_gt(self):
super_, sub_, twin1, twin2, unique1, unique2 = self._create_sets()
# basic set math
eq_(sub_ > super_, False)
eq_(super_ > sub_, True)
# the same sets
eq_(twin1 > twin2, False)
eq_(twin2 > twin1, False)
# totally different sets
eq_(unique1 > unique2, False)
eq_(unique2 > unique1, False)
# not an IdentitySet
def should_raise():
not_an_identity_set = object()
return unique1 > not_an_identity_set
self._assert_unorderable_types(should_raise)
示例4: test_issubset
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import IdentitySet [as 別名]
def test_issubset(self):
super_, sub_, twin1, twin2, unique1, unique2 = self._create_sets()
# basic set math
eq_(sub_.issubset(super_), True)
eq_(super_.issubset(sub_), False)
# the same sets
eq_(twin1.issubset(twin2), True)
eq_(twin2.issubset(twin1), True)
# totally different sets
eq_(unique1.issubset(unique2), False)
eq_(unique2.issubset(unique1), False)
# not an IdentitySet
not_an_identity_set = object()
assert_raises(TypeError, unique1.issubset, not_an_identity_set)
示例5: test_issuperset
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import IdentitySet [as 別名]
def test_issuperset(self):
super_, sub_, twin1, twin2, unique1, unique2 = self._create_sets()
# basic set math
eq_(sub_.issuperset(super_), False)
eq_(super_.issuperset(sub_), True)
# the same sets
eq_(twin1.issuperset(twin2), True)
eq_(twin2.issuperset(twin1), True)
# totally different sets
eq_(unique1.issuperset(unique2), False)
eq_(unique2.issuperset(unique1), False)
# not an IdentitySet
not_an_identity_set = object()
assert_raises(TypeError, unique1.issuperset, not_an_identity_set)
示例6: test_dunder_ior
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import IdentitySet [as 別名]
def test_dunder_ior(self):
super_, sub_, _, _, _, _ = self._create_sets()
# basic set math
sub_ |= super_
eq_(sub_, super_)
super_ |= sub_
eq_(super_, super_)
# totally different sets
unique1 = util.IdentitySet([1])
unique2 = util.IdentitySet([2])
unique1 |= unique2
eq_(unique1, util.IdentitySet([1, 2]))
eq_(unique2, util.IdentitySet([2]))
# not an IdentitySet
def should_raise():
unique = util.IdentitySet([1])
not_an_identity_set = object()
unique |= not_an_identity_set
assert_raises(TypeError, should_raise)
示例7: test_intersection
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import IdentitySet [as 別名]
def test_intersection(self):
super_, sub_, twin1, twin2, unique1, unique2 = self._create_sets()
# basic set math
eq_(sub_.intersection(super_), sub_)
eq_(super_.intersection(sub_), sub_)
# the same sets
eq_(twin1.intersection(twin2), twin1)
eq_(twin2.intersection(twin1), twin1)
# empty sets
empty = util.IdentitySet([])
eq_(empty.intersection(empty), empty)
# totally different sets
eq_(unique1.intersection(unique2), empty)
# not an IdentitySet
not_an_identity_set = object()
assert_raises(TypeError, unique1.intersection, not_an_identity_set)
示例8: test_init
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import IdentitySet [as 別名]
def test_init(self):
ids = util.IdentitySet([1, 2, 3, 2, 1])
self.assert_eq(ids, [1, 2, 3])
ids = util.IdentitySet(ids)
self.assert_eq(ids, [1, 2, 3])
ids = util.IdentitySet()
self.assert_eq(ids, [])
ids = util.IdentitySet([])
self.assert_eq(ids, [])
ids = util.IdentitySet(ids)
self.assert_eq(ids, [])
示例9: test_add
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import IdentitySet [as 別名]
def test_add(self):
for type_ in (object, ImmutableSubclass):
data = [type_(), type_()]
ids = util.IdentitySet()
for i in list(range(2)) + list(range(2)):
ids.add(data[i])
self.assert_eq(ids, data)
for type_ in (NoHash, EqOverride, HashOverride, HashEqOverride):
data = [type_(1), type_(1), type_(2)]
ids = util.IdentitySet()
for i in list(range(3)) + list(range(3)):
ids.add(data[i])
self.assert_eq(ids, data)
示例10: test_dunder_sub2
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import IdentitySet [as 別名]
def test_dunder_sub2(self):
IdentitySet = util.IdentitySet
o1, o2, o3 = self.obj_type(), self.obj_type(), self.obj_type()
ids1 = IdentitySet([o1])
ids2 = IdentitySet([o1, o2, o3])
eq_(ids2 - ids1, IdentitySet([o2, o3]))
ids2 -= ids1
eq_(ids2, IdentitySet([o2, o3]))
示例11: test_dunder_eq
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import IdentitySet [as 別名]
def test_dunder_eq(self):
_, _, twin1, twin2, unique1, unique2 = self._create_sets()
# basic set math
eq_(twin1 == twin2, True)
eq_(unique1 == unique2, False)
# not an IdentitySet
not_an_identity_set = object()
eq_(unique1 == not_an_identity_set, False)
示例12: test_dunder_ne
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import IdentitySet [as 別名]
def test_dunder_ne(self):
_, _, twin1, twin2, unique1, unique2 = self._create_sets()
# basic set math
eq_(twin1 != twin2, False)
eq_(unique1 != unique2, True)
# not an IdentitySet
not_an_identity_set = object()
eq_(unique1 != not_an_identity_set, True)
示例13: test_dunder_or
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import IdentitySet [as 別名]
def test_dunder_or(self):
super_, sub_, twin1, twin2, _, _ = self._create_sets()
# basic set math
eq_(sub_ | super_, super_)
eq_(super_ | sub_, super_)
# the same sets
eq_(twin1 | twin2, twin1)
eq_(twin2 | twin1, twin1)
# empty sets
empty = util.IdentitySet([])
eq_(empty | empty, empty)
# totally different sets
unique1 = util.IdentitySet([1])
unique2 = util.IdentitySet([2])
eq_(unique1 | unique2, util.IdentitySet([1, 2]))
# not an IdentitySet
def should_raise():
not_an_identity_set = object()
return unique1 | not_an_identity_set
assert_raises(TypeError, should_raise)
示例14: test_difference
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import IdentitySet [as 別名]
def test_difference(self):
_, _, twin1, twin2, _, _ = self._create_sets()
# basic set math
set1 = util.IdentitySet([1, 2, 3])
set2 = util.IdentitySet([2, 3, 4])
eq_(set1.difference(set2), util.IdentitySet([1]))
eq_(set2.difference(set1), util.IdentitySet([4]))
# empty sets
empty = util.IdentitySet([])
eq_(empty.difference(empty), empty)
# the same sets
eq_(twin1.difference(twin2), empty)
eq_(twin2.difference(twin1), empty)
# totally different sets
unique1 = util.IdentitySet([1])
unique2 = util.IdentitySet([2])
eq_(unique1.difference(unique2), util.IdentitySet([1]))
eq_(unique2.difference(unique1), util.IdentitySet([2]))
# not an IdentitySet
not_an_identity_set = object()
assert_raises(TypeError, unique1.difference, not_an_identity_set)
示例15: test_dunder_sub
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import IdentitySet [as 別名]
def test_dunder_sub(self):
_, _, twin1, twin2, _, _ = self._create_sets()
# basic set math
set1 = util.IdentitySet([1, 2, 3])
set2 = util.IdentitySet([2, 3, 4])
eq_(set1 - set2, util.IdentitySet([1]))
eq_(set2 - set1, util.IdentitySet([4]))
# empty sets
empty = util.IdentitySet([])
eq_(empty - empty, empty)
# the same sets
eq_(twin1 - twin2, empty)
eq_(twin2 - twin1, empty)
# totally different sets
unique1 = util.IdentitySet([1])
unique2 = util.IdentitySet([2])
eq_(unique1 - unique2, util.IdentitySet([1]))
eq_(unique2 - unique1, util.IdentitySet([2]))
# not an IdentitySet
def should_raise():
not_an_identity_set = object()
unique1 - not_an_identity_set
assert_raises(TypeError, should_raise)