mirror of
https://github.com/zhigang1992/mitmproxy.git
synced 2026-04-30 05:05:02 +08:00
Merge pull request #2145 from mhils/ne
py3: __ne__ delegates to __eq__ by default
This commit is contained in:
@@ -384,9 +384,6 @@ class SSLCert(serializable.Serializable):
|
|||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
return self.digest("sha256") == other.digest("sha256")
|
return self.digest("sha256") == other.digest("sha256")
|
||||||
|
|
||||||
def __ne__(self, other):
|
|
||||||
return not self.__eq__(other)
|
|
||||||
|
|
||||||
def get_state(self):
|
def get_state(self):
|
||||||
return self.to_pem()
|
return self.to_pem()
|
||||||
|
|
||||||
|
|||||||
@@ -13,9 +13,6 @@ class MessageData(serializable.Serializable):
|
|||||||
return self.__dict__ == other.__dict__
|
return self.__dict__ == other.__dict__
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def __ne__(self, other):
|
|
||||||
return not self.__eq__(other)
|
|
||||||
|
|
||||||
def set_state(self, state):
|
def set_state(self, state):
|
||||||
for k, v in state.items():
|
for k, v in state.items():
|
||||||
if k == "headers":
|
if k == "headers":
|
||||||
@@ -39,9 +36,6 @@ class Message(serializable.Serializable):
|
|||||||
return self.data == other.data
|
return self.data == other.data
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def __ne__(self, other):
|
|
||||||
return not self.__eq__(other)
|
|
||||||
|
|
||||||
def get_state(self):
|
def get_state(self):
|
||||||
return self.data.get_state()
|
return self.data.get_state()
|
||||||
|
|
||||||
|
|||||||
@@ -67,9 +67,6 @@ class _MultiDict(MutableMapping, serializable.Serializable, metaclass=ABCMeta):
|
|||||||
return self.fields == other.fields
|
return self.fields == other.fields
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def __ne__(self, other):
|
|
||||||
return not self.__eq__(other)
|
|
||||||
|
|
||||||
def get_all(self, key):
|
def get_all(self, key):
|
||||||
"""
|
"""
|
||||||
Return the list of all values for a given key.
|
Return the list of all values for a given key.
|
||||||
|
|||||||
@@ -38,14 +38,12 @@ def _test_decoded_attr(message, attr):
|
|||||||
|
|
||||||
|
|
||||||
class TestMessageData:
|
class TestMessageData:
|
||||||
def test_eq_ne(self):
|
def test_eq(self):
|
||||||
data = tutils.tresp(timestamp_start=42, timestamp_end=42).data
|
data = tutils.tresp(timestamp_start=42, timestamp_end=42).data
|
||||||
same = tutils.tresp(timestamp_start=42, timestamp_end=42).data
|
same = tutils.tresp(timestamp_start=42, timestamp_end=42).data
|
||||||
assert data == same
|
assert data == same
|
||||||
assert not data != same
|
|
||||||
|
|
||||||
other = tutils.tresp(content=b"foo").data
|
other = tutils.tresp(content=b"foo").data
|
||||||
assert not data == other
|
|
||||||
assert data != other
|
assert data != other
|
||||||
|
|
||||||
assert data != 0
|
assert data != 0
|
||||||
@@ -61,10 +59,8 @@ class TestMessage:
|
|||||||
resp = tutils.tresp(timestamp_start=42, timestamp_end=42)
|
resp = tutils.tresp(timestamp_start=42, timestamp_end=42)
|
||||||
same = tutils.tresp(timestamp_start=42, timestamp_end=42)
|
same = tutils.tresp(timestamp_start=42, timestamp_end=42)
|
||||||
assert resp == same
|
assert resp == same
|
||||||
assert not resp != same
|
|
||||||
|
|
||||||
other = tutils.tresp(timestamp_start=0, timestamp_end=0)
|
other = tutils.tresp(timestamp_start=0, timestamp_end=0)
|
||||||
assert not resp == other
|
|
||||||
assert resp != other
|
assert resp != other
|
||||||
|
|
||||||
assert resp != 0
|
assert resp != 0
|
||||||
|
|||||||
@@ -160,7 +160,6 @@ class TestSSLCert:
|
|||||||
assert c2.to_pem()
|
assert c2.to_pem()
|
||||||
assert c2.has_expired is not None
|
assert c2.has_expired is not None
|
||||||
|
|
||||||
assert not c1 == c2
|
|
||||||
assert c1 != c2
|
assert c1 != c2
|
||||||
|
|
||||||
def test_err_broken_sans(self):
|
def test_err_broken_sans(self):
|
||||||
|
|||||||
@@ -93,11 +93,6 @@ class TestMultiDict:
|
|||||||
md1.fields = md1.fields[1:] + md1.fields[:1]
|
md1.fields = md1.fields[1:] + md1.fields[:1]
|
||||||
assert not (md1 == md2)
|
assert not (md1 == md2)
|
||||||
|
|
||||||
def test_ne(self):
|
|
||||||
assert not TMultiDict() != TMultiDict()
|
|
||||||
assert TMultiDict() != self._multi()
|
|
||||||
assert TMultiDict() != 42
|
|
||||||
|
|
||||||
def test_hash(self):
|
def test_hash(self):
|
||||||
"""
|
"""
|
||||||
If a class defines mutable objects and implements an __eq__() method,
|
If a class defines mutable objects and implements an __eq__() method,
|
||||||
|
|||||||
Reference in New Issue
Block a user