示例#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)
示例#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)
示例#3
0
 def test_decimal_to_dt_with_none_parameter(self):
     self.assertIsNone(utils.decimal_to_dt(None))
示例#4
0
文件: models.py 项目: openstack/panko
 def process_result_value(value, dialect):
     if value is None:
         return value
     elif dialect.name == 'mysql':
         return utils.decimal_to_dt(value)
     return value
示例#5
0
 def test_decimal_to_dt_with_none_parameter(self):
     self.assertIsNone(utils.decimal_to_dt(None))
示例#6
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