Skip to content

Commit

Permalink
Fix StreamResponse equality (#3107)
Browse files Browse the repository at this point in the history
  • Loading branch information
NotSqrt authored and asvetlov committed Jun 26, 2018
1 parent 80b8d7a commit 3a65252
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES/3100.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix `StreamResponse` equality, now that they are `MutableMapping` objects.
3 changes: 3 additions & 0 deletions aiohttp/web_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,9 @@ def __iter__(self):
def __hash__(self):
return hash(id(self))

def __eq__(self, other):
return self is other


class Response(StreamResponse):

Expand Down
8 changes: 8 additions & 0 deletions tests/test_web_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ def test_stream_response_hashable():
hash(StreamResponse())


def test_stream_response_eq():
resp1 = StreamResponse()
resp2 = StreamResponse()

assert resp1 == resp1
assert not resp1 == resp2


def test_stream_response_is_mutable_mapping():
resp = StreamResponse()
assert isinstance(resp, collections.MutableMapping)
Expand Down

0 comments on commit 3a65252

Please sign in to comment.