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)
def test_decimal_to_dt_with_none_parameter(self): self.assertIsNone(utils.decimal_to_dt(None))
def process_result_value(value, dialect): if value is None: return value elif dialect.name == 'mysql': return utils.decimal_to_dt(value) return value