Skip to content

Commit

Permalink
Fix #3116: correctly compare request objects
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Jul 9, 2018
1 parent 5bbc255 commit d0dbb06
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES/3116.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix server request objects comparison
3 changes: 3 additions & 0 deletions aiohttp/web_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,9 @@ def __repr__(self):
return "<{} {} {} >".format(self.__class__.__name__,
self._method, ascii_encodable_path)

def __eq__(self, other):
return id(self) == id(other)

@asyncio.coroutine
def _prepare_hook(self, response):
return
Expand Down
7 changes: 7 additions & 0 deletions tests/test_web_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,3 +634,10 @@ def test_remote_with_closed_transport():
req = make_mocked_request('GET', '/')
req._protocol = None
assert req.remote is None


def test_eq():
req1 = make_mocked_request('GET', '/path/to?a=1&b=2')
req2 = make_mocked_request('GET', '/path/to?a=1&b=2')
assert req1 != req2
assert req1 == req1

0 comments on commit d0dbb06

Please sign in to comment.