mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-12-01 13:13:45 +03:00
raising an exception here rather than returning False causes problems with SQLAlchemy's internal state tracking
This commit is contained in:
parent
8bb44f3444
commit
b6a9e0ffaf
|
@ -122,7 +122,7 @@ class Range(object):
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
if not isinstance(other, self.__class__):
|
if not isinstance(other, self.__class__):
|
||||||
raise TypeError('Cannot compare %r with %r' % (self, other))
|
return False
|
||||||
return (self._lower == other._lower
|
return (self._lower == other._lower
|
||||||
and self._upper == other._upper
|
and self._upper == other._upper
|
||||||
and self._bounds == other._bounds)
|
and self._bounds == other._bounds)
|
||||||
|
|
|
@ -1214,13 +1214,7 @@ class RangeTestCase(unittest.TestCase):
|
||||||
|
|
||||||
def test_eq_wrong_type(self):
|
def test_eq_wrong_type(self):
|
||||||
from psycopg2.extras import Range
|
from psycopg2.extras import Range
|
||||||
try:
|
self.assertFalse(Range(10, 20)==())
|
||||||
Range(10, 20)==()
|
|
||||||
except TypeError, e:
|
|
||||||
self.assertEqual(
|
|
||||||
str(e), "Cannot compare Range(10, 20, '[)') with ()")
|
|
||||||
else:
|
|
||||||
self.fail('No exception raised')
|
|
||||||
|
|
||||||
def test_not_ordered(self):
|
def test_not_ordered(self):
|
||||||
from psycopg2.extras import Range
|
from psycopg2.extras import Range
|
||||||
|
|
Loading…
Reference in New Issue
Block a user