~psycopg/psycopg/2.0.x

« back to all changes in this revision

Viewing changes to tests/types_basic.py

  • Committer: Federico Di Gregorio
  • Date: 2009-01-22 23:09:20 UTC
  • Revision ID: fog@initd.org-20090122230920-3o0yr9v00990klog
Added adapter to handle float('inf') and float('nan')

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
            self.failUnless(abs(s - 19.10) < 0.001,
61
61
                            "wrong float quoting: " + str(s))
62
62
 
 
63
    def testFloat(self):
 
64
        s = self.execute("SELECT %s AS foo", (float("nan"),))
 
65
        self.failUnless(str(s) == "nan", "wrong float quoting: " + str(s))
 
66
        self.failUnless(type(s) == float, "wrong float conversion: " + repr(s))
 
67
        s = self.execute("SELECT %s AS foo", (float("inf"),))
 
68
        self.failUnless(str(s) == "inf", "wrong float quoting: " + str(s))      
 
69
        self.failUnless(type(s) == float, "wrong float conversion: " + repr(s))
 
70
 
63
71
    def testBinary(self):
64
72
        s = ''.join([chr(x) for x in range(256)])
65
73
        b = psycopg2.Binary(s)