Skip to content

Commit

Permalink
fix Range.__hash__
Browse files Browse the repository at this point in the history
remove `other` from parameter list of `__hash__`
  • Loading branch information
eumiro authored and 1st1 committed Nov 30, 2017
1 parent 695b8f0 commit 46f468c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion asyncpg/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def __eq__(self, other):
other._empty
)

def __hash__(self, other):
def __hash__(self):
return hash((
self._lower,
self._upper,
Expand Down
10 changes: 10 additions & 0 deletions tests/test_codecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,16 @@ async def test_range_types(self):
ValueError, 'expected 0, 1 or 2 elements'):
await self.con.fetch("SELECT $1::int4range", (0, 2, 3))

cases = [(asyncpg.Range(0, 1), asyncpg.Range(0, 1), 1),
(asyncpg.Range(0, 1), asyncpg.Range(0, 2), 2),
(asyncpg.Range(empty=True), asyncpg.Range(0, 2), 2),
(asyncpg.Range(empty=True), asyncpg.Range(empty=True), 1),
(asyncpg.Range(0, 1, upper_inc=True), asyncpg.Range(0, 1), 2),
]
for obj_a, obj_b, count in cases:
dic = {obj_a: 1, obj_b: 2}
self.assertEqual(len(dic), count)

async def test_extra_codec_alias(self):
"""Test encoding/decoding of a builtin non-pg_catalog codec."""
await self.con.execute('''
Expand Down

0 comments on commit 46f468c

Please sign in to comment.