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


Python util.FancyEqMixin方法代码示例

本文整理汇总了Python中twisted.python.util.FancyEqMixin方法的典型用法代码示例。如果您正苦于以下问题:Python util.FancyEqMixin方法的具体用法?Python util.FancyEqMixin怎么用?Python util.FancyEqMixin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.python.util的用法示例。


在下文中一共展示了util.FancyEqMixin方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __eq__

# 需要导入模块: from twisted.python import util [as 别名]
# 或者: from twisted.python.util import FancyEqMixin [as 别名]
def __eq__(self, other):
            """
            Overriding C{FancyEqMixin} to ensure the os level samefile
            check is done if the name attributes do not match.
            """
            res = super(UNIXAddress, self).__eq__(other)
            if not res and self.name and other.name:
                try:
                    return os.path.samefile(self.name, other.name)
                except OSError:
                    pass
                except (TypeError, ValueError) as e:
                    # On Linux, abstract namespace UNIX sockets start with a
                    # \0, which os.path doesn't like.
                    if not _PY3 and not platform.isLinux():
                        raise e
            return res 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:19,代码来源:address.py

示例2: test_identity

# 需要导入模块: from twisted.python import util [as 别名]
# 或者: from twisted.python.util import FancyEqMixin [as 别名]
def test_identity(self):
        """
        Instances of a class which mixes in L{FancyEqMixin} but which
        defines no comparison attributes compare by identity.
        """
        class Empty(util.FancyEqMixin):
            pass

        self.assertFalse(Empty() == Empty())
        self.assertTrue(Empty() != Empty())
        empty = Empty()
        self.assertTrue(empty == empty)
        self.assertFalse(empty != empty) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:15,代码来源:test_util.py

示例3: test_equality

# 需要导入模块: from twisted.python import util [as 别名]
# 或者: from twisted.python.util import FancyEqMixin [as 别名]
def test_equality(self):
        """
        Instances of a class which mixes in L{FancyEqMixin} should compare
        equal if all of their attributes compare equal.  They should not
        compare equal if any of their attributes do not compare equal.
        """
        self.assertTrue(Record(1, 2) == Record(1, 2))
        self.assertFalse(Record(1, 2) == Record(1, 3))
        self.assertFalse(Record(1, 2) == Record(2, 2))
        self.assertFalse(Record(1, 2) == Record(3, 4)) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:12,代码来源:test_util.py

示例4: test_differentClassesEquality

# 需要导入模块: from twisted.python import util [as 别名]
# 或者: from twisted.python.util import FancyEqMixin [as 别名]
def test_differentClassesEquality(self):
        """
        Instances of different classes which mix in L{FancyEqMixin} should not
        compare equal.
        """
        self.assertFalse(Record(1, 2) == DifferentRecord(1, 2)) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:8,代码来源:test_util.py

示例5: test_differentClassesInequality

# 需要导入模块: from twisted.python import util [as 别名]
# 或者: from twisted.python.util import FancyEqMixin [as 别名]
def test_differentClassesInequality(self):
        """
        Instances of different classes which mix in L{FancyEqMixin} should
        compare unequal.
        """
        self.assertTrue(Record(1, 2) != DifferentRecord(1, 2)) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:8,代码来源:test_util.py

示例6: test_inheritedClassesInequality

# 需要导入模块: from twisted.python import util [as 别名]
# 或者: from twisted.python.util import FancyEqMixin [as 别名]
def test_inheritedClassesInequality(self):
        """
        An instance of a class which derives from a class which mixes in
        L{FancyEqMixin} should compare unequal to an instance of the base
        class if any of their attributes compare unequal.
        """
        self.assertFalse(Record(1, 2) != DerivedRecord(1, 2))
        self.assertTrue(Record(1, 2) != DerivedRecord(1, 3))
        self.assertTrue(Record(1, 2) != DerivedRecord(2, 2))
        self.assertTrue(Record(1, 2) != DerivedRecord(3, 4)) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:12,代码来源:test_util.py

示例7: test_rightHandArgumentImplementsEquality

# 需要导入模块: from twisted.python import util [as 别名]
# 或者: from twisted.python.util import FancyEqMixin [as 别名]
def test_rightHandArgumentImplementsEquality(self):
        """
        The right-hand argument to the equality operator is given a chance
        to determine the result of the operation if it is of a type
        unrelated to the L{FancyEqMixin}-based instance on the left-hand
        side.
        """
        self.assertTrue(Record(1, 2) == EqualToEverything())
        self.assertFalse(Record(1, 2) == EqualToNothing()) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:11,代码来源:test_util.py

示例8: test_rightHandArgumentImplementsUnequality

# 需要导入模块: from twisted.python import util [as 别名]
# 或者: from twisted.python.util import FancyEqMixin [as 别名]
def test_rightHandArgumentImplementsUnequality(self):
        """
        The right-hand argument to the non-equality operator is given a
        chance to determine the result of the operation if it is of a type
        unrelated to the L{FancyEqMixin}-based instance on the left-hand
        side.
        """
        self.assertFalse(Record(1, 2) != EqualToEverything())
        self.assertTrue(Record(1, 2) != EqualToNothing()) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:11,代码来源:test_util.py

示例9: test_inheritedClassesEquality

# 需要导入模块: from twisted.python import util [as 别名]
# 或者: from twisted.python.util import FancyEqMixin [as 别名]
def test_inheritedClassesEquality(self):
        """
        An instance of a class which derives from a class which mixes in
        L{FancyEqMixin} should compare equal to an instance of the base class
        if and only if all of their attributes compare equal.
        """
        self.assertTrue(Record(1, 2) == DerivedRecord(1, 2))
        self.assertFalse(Record(1, 2) == DerivedRecord(1, 3))
        self.assertFalse(Record(1, 2) == DerivedRecord(2, 2))
        self.assertFalse(Record(1, 2) == DerivedRecord(3, 4)) 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:12,代码来源:test_util.py


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