Float test skipped where the server doesn't support inf.

This commit is contained in:
Daniele Varrazzo 2010-11-19 10:44:39 +00:00
parent a55e50b991
commit 21dfc2c592

View File

@ -81,7 +81,7 @@ class TypesBasicTests(unittest.TestCase):
else: else:
return self.skipTest("decimal not available") return self.skipTest("decimal not available")
def testFloat(self): def testFloatNan(self):
try: try:
float("nan") float("nan")
except ValueError: except ValueError:
@ -90,6 +90,13 @@ class TypesBasicTests(unittest.TestCase):
s = self.execute("SELECT %s AS foo", (float("nan"),)) s = self.execute("SELECT %s AS foo", (float("nan"),))
self.failUnless(str(s) == "nan", "wrong float quoting: " + str(s)) self.failUnless(str(s) == "nan", "wrong float quoting: " + str(s))
self.failUnless(type(s) == float, "wrong float conversion: " + repr(s)) self.failUnless(type(s) == float, "wrong float conversion: " + repr(s))
def testFloatInf(self):
try:
self.execute("select 'inf'::float")
except psycopg2.DataError:
return self.skipTest("inf::float not available on the server")
s = self.execute("SELECT %s AS foo", (float("inf"),)) s = self.execute("SELECT %s AS foo", (float("inf"),))
self.failUnless(str(s) == "inf", "wrong float quoting: " + str(s)) self.failUnless(str(s) == "inf", "wrong float quoting: " + str(s))
self.failUnless(type(s) == float, "wrong float conversion: " + repr(s)) self.failUnless(type(s) == float, "wrong float conversion: " + repr(s))