當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。