mirror of https://github.com/secdev/scapy.git
Remove __cmp__ (fix tests)
This commit is contained in:
parent
5b9f508b4f
commit
5f3080bc2d
|
@ -204,8 +204,16 @@ class ASN1_Object(six.with_metaclass(ASN1_Object_metaclass)):
|
|||
print(self.strshow(lvl))
|
||||
def __eq__(self, other):
|
||||
return self.val == other
|
||||
def __cmp__(self, other):
|
||||
return cmp(self.val, other)
|
||||
def __lt__(self, other):
|
||||
return self.val < other
|
||||
def __le__(self, other):
|
||||
return self.val <= other
|
||||
def __gt__(self, other):
|
||||
return self.val > other
|
||||
def __ge__(self, other):
|
||||
return self.val >= other
|
||||
def __ne__(self, other):
|
||||
return self.val != other
|
||||
|
||||
|
||||
#######################
|
||||
|
|
|
@ -1033,8 +1033,18 @@ class FlagValue(object):
|
|||
self.value = self._fixvalue(value)
|
||||
def __int__(self):
|
||||
return self.value
|
||||
def __cmp__(self, other):
|
||||
return cmp(self.value, self._fixvalue(other))
|
||||
def __eq__(self, other):
|
||||
return self.value == self._fixvalue(other)
|
||||
def __lt__(self, other):
|
||||
return self.value < self._fixvalue(other)
|
||||
def __le__(self, other):
|
||||
return self.value <= self._fixvalue(other)
|
||||
def __gt__(self, other):
|
||||
return self.value > self._fixvalue(other)
|
||||
def __ge__(self, other):
|
||||
return self.value >= self._fixvalue(other)
|
||||
def __ne__(self, other):
|
||||
return self.value != self._fixvalue(other)
|
||||
def __and__(self, other):
|
||||
return self.__class__(self.value & self._fixvalue(other), self.names)
|
||||
__rand__ = __and__
|
||||
|
|
|
@ -71,16 +71,15 @@ class RandomEnumeration:
|
|||
class VolatileValue:
|
||||
def __repr__(self):
|
||||
return "<%s>" % self.__class__.__name__
|
||||
def __eq__(self, other):
|
||||
x = self._fix()
|
||||
y = other._fix() if isinstance(other, VolatileValue) else other
|
||||
if not isinstance(x, type(y)):
|
||||
return False
|
||||
return x == y
|
||||
def __getattr__(self, attr):
|
||||
if attr == "__setstate__":
|
||||
raise AttributeError(attr)
|
||||
elif attr == "__cmp__":
|
||||
x = self._fix()
|
||||
def cmp2(y,x=x):
|
||||
if not isinstance(x, type(y)):
|
||||
return -1
|
||||
return x.__cmp__(y)
|
||||
return cmp2
|
||||
return getattr(self._fix(),attr)
|
||||
def _fix(self):
|
||||
return None
|
||||
|
|
|
@ -8039,10 +8039,10 @@ assert(r6 == "d279:1205:e445:5a9f:db28:efc9:afd7:f594")
|
|||
|
||||
random.seed(0x2807)
|
||||
r6 = RandIP6("2001:db8::-")
|
||||
assert(r6 == "2001:0db8::afd7")
|
||||
assert(r6 == "2001:0db8::e445")
|
||||
|
||||
r6 = RandIP6("2001:db8::*")
|
||||
assert(r6 == "2001:0db8::398e")
|
||||
assert(r6 == "2001:0db8::efc9")
|
||||
|
||||
= RandMAC
|
||||
|
||||
|
@ -8091,6 +8091,7 @@ assert(rek == 'b')
|
|||
~ not_pypy
|
||||
random.seed(0x2807)
|
||||
rs = RandSingNum(-28, 07)
|
||||
assert(rs == 3)
|
||||
assert(rs == -27)
|
||||
|
||||
= Rand*
|
||||
|
|
Loading…
Reference in New Issue