当前位置: 首页>>代码示例>>Python>>正文


Python util.IdentitySet方法代码示例

本文整理汇总了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) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:23,代码来源:test_utils.py

示例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) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:23,代码来源:test_utils.py

示例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) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:23,代码来源:test_utils.py

示例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) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:20,代码来源:test_utils.py

示例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) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:20,代码来源:test_utils.py

示例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) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:25,代码来源:test_utils.py

示例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) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:23,代码来源:test_utils.py

示例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, []) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:17,代码来源:test_utils.py

示例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) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:16,代码来源:test_utils.py

示例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])) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:11,代码来源:test_utils.py

示例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) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:12,代码来源:test_utils.py

示例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) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:12,代码来源:test_utils.py

示例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) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:28,代码来源:test_utils.py

示例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) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:28,代码来源:test_utils.py

示例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) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:31,代码来源:test_utils.py


注:本文中的sqlalchemy.util.IdentitySet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。