mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-22 17:06:33 +03:00
Merge branch 'range_eq_typerror'
This commit is contained in:
commit
ea08f7e7c7
2
NEWS
2
NEWS
|
@ -3,6 +3,8 @@ What's new in psycopg 2.5.1
|
|||
|
||||
- Fixed build on Solaris 10 and 11 where the round() function is already
|
||||
declared (:ticket:`#146`).
|
||||
- Fixed comparison of `Range` with non-range objects (:ticket:`#164`).
|
||||
Thanks to Chris Withers for the patch.
|
||||
|
||||
|
||||
What's new in psycopg 2.5
|
||||
|
|
|
@ -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.assertNotEqual(Range(10, 20), ())
|
||||
|
||||
def test_eq_subclass(self):
|
||||
from psycopg2.extras import Range, NumericRange
|
||||
|
||||
class IntRange(NumericRange): pass
|
||||
class PositiveIntRange(IntRange): pass
|
||||
|
||||
self.assertEqual(Range(10, 20), IntRange(10, 20))
|
||||
self.assertEqual(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