本文整理汇总了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
示例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)
示例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))
示例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))
示例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))
示例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))
示例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())
示例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())
示例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))