mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-08-04 12:20:09 +03:00
Merge 28276e3eb1
into bbe0bf955c
This commit is contained in:
commit
faf7ff4d2f
|
@ -121,6 +121,8 @@ class Range(object):
|
|||
return self._bounds is not None
|
||||
|
||||
def __eq__(self, other):
|
||||
if not isinstance(other, Range):
|
||||
return False
|
||||
return (self._lower == other._lower
|
||||
and self._upper == other._upper
|
||||
and self._bounds == other._bounds)
|
||||
|
|
|
@ -1212,6 +1212,19 @@ class RangeTestCase(unittest.TestCase):
|
|||
assert_not_equal(Range(10, 20), Range(11, 20))
|
||||
assert_not_equal(Range(10, 20, '[)'), Range(10, 20, '[]'))
|
||||
|
||||
def test_eq_wrong_type(self):
|
||||
from psycopg2.extras import Range
|
||||
self.assertFalse(Range(10, 20)==())
|
||||
|
||||
def test_eq_subclass(self):
|
||||
from psycopg2.extras import Range, NumericRange
|
||||
|
||||
class IntRange(NumericRange): pass
|
||||
class PositiveIntRange(IntRange): pass
|
||||
|
||||
self.assertTrue(Range(10, 20)==IntRange(10, 20))
|
||||
self.assertTrue(PositiveIntRange(10, 20)==IntRange(10, 20))
|
||||
|
||||
def test_not_ordered(self):
|
||||
from psycopg2.extras import Range
|
||||
self.assertRaises(TypeError, lambda: Range(empty=True) < Range(0,4))
|
||||
|
|
Loading…
Reference in New Issue
Block a user