Exemplo n.º 1
0
 def test_decimal_to_datetime(self):
     expected = 1356093296.12
     dexpected = decimal.Decimal(str(expected))  # Python 2.6 wants str()
     expected_datetime = datetime.datetime.utcfromtimestamp(expected)
     actual_datetime = utils.decimal_to_dt(dexpected)
     # Python 3 have rounding issue on this, so use float
     self.assertAlmostEqual(utils.dt_to_decimal(expected_datetime),
                            utils.dt_to_decimal(actual_datetime),
                            places=5)
Exemplo n.º 2
0
 def test_decimal_to_datetime(self):
     expected = 1356093296.12
     dexpected = decimal.Decimal(str(expected))  # Python 2.6 wants str()
     expected_datetime = datetime.datetime.utcfromtimestamp(expected)
     actual_datetime = utils.decimal_to_dt(dexpected)
     # Python 3 have rounding issue on this, so use float
     self.assertAlmostEqual(utils.dt_to_decimal(expected_datetime),
                            utils.dt_to_decimal(actual_datetime),
                            places=5)
Exemplo n.º 3
0
 def process_result_value(value, dialect):
     if value is None:
         return value
     elif dialect.name == 'mysql':
         return utils.decimal_to_dt(value)
     return value
Exemplo n.º 4
0
 def test_decimal_to_dt_with_none_parameter(self):
     self.assertIsNone(utils.decimal_to_dt(None))
Exemplo n.º 5
0
 def process_result_value(value, dialect):
     if value is None:
         return value
     elif dialect.name == 'mysql':
         return utils.decimal_to_dt(value)
     return value
Exemplo n.º 6
0
 def test_decimal_to_dt_with_none_parameter(self):
     self.assertIsNone(utils.decimal_to_dt(None))