Пример #1
0
    def testArithmeticOperations(self):
        """ check some arithmetic operations """
        x = FLOAT(22.34)
        y = FLOAT(7.89)
        self.assertGreater(x, y)

        x += y
        self.assertEqual(x, 30.23)

        x *= y  # x is no longer a FLOAT...
        self.assertEqual(x, 238.5147)

        self.assertEqual(FLOAT('2.6') / 2, FLOAT('1.3'))
Пример #2
0
 def testSQLOutput(self):
     """ check quoted and unquoted output for sql """
     x = FLOAT('22.34')
     self.assertEqual(x.sql(), "'22.34'")
     self.assertEqual(x.sql(quoted=False), "22.34")
Пример #3
0
 def testSqlType(self):
     """ check sql type """
     a = FLOAT(1.23)
     self.assertEqual(a._v_mysql_type, "float")
Пример #4
0
 def testStringCreation(self):
     """ check instance creation - string parameter """
     x = FLOAT('22.34')
     self.assertEqual(x, 22.34)
Пример #5
0
 def testInvalidCreation(self):
     """ check creation with invalid string input """
     y = FLOAT('hello')
     self.assertEqual(y, 0)
Пример #6
0
 def testNumericCreation(self):
     """ check instance creation - numeric parameter """
     y = FLOAT(7.33)
     self.assertEqual(y, 7.33)
Пример #7
0
 def testDefaultCreation(self):
     """ check instance creation - no parameter defaults to 0 """
     x = FLOAT()
     self.assertEqual(x, 0)
Пример #8
0
 def testSQLOutput(self):
     """ check quoted and unquoted output for sql """
     x = FLOAT('22.34')
     self.assertEqual(x.sql(), "'22.34'")
     self.assertEqual(x.sql(quoted=False), "22.34")