def test_encoder_missing(self): """If no encoder is found, raise ValueError""" from datetime import datetime dynamizer = Dynamizer() with self.assertRaises(ValueError): dynamizer.encode(datetime.utcnow())
def test_register_encoder(self): """ Can register a custom encoder """ from datetime import datetime dynamizer = Dynamizer() dynamizer.register_encoder(datetime, lambda d, v: (STRING, v.isoformat())) now = datetime.utcnow() self.assertEqual(dynamizer.raw_encode(now), (STRING, now.isoformat()))
def test_encoder_missing(self): """ If no encoder is found, raise ValueError """ from datetime import datetime dynamizer = Dynamizer() with self.assertRaises(ValueError): dynamizer.encode(datetime.utcnow())