Ejemplo n.º 1
0
 def test_floatfield_1(self):
     f = FloatField('kWh')
     pytest.raises(ValidationError, f.clean, None)
     pytest.raises(ValidationError, f.clean, 10.2 * registry.meter)
     pytest.raises(ValidationError, f.clean, 'abc')
     assert 10.2 * registry.kilowatt_hour == f.clean(10.2 * registry.kilowatt_hour)
     assert 10.2 * registry['kWh'] == f.clean(10.2)
     assert 10.2 * registry['kWh'] == f.clean((10.2, 'kWh'))
     assert 10.2 * registry['kWh'] == f.clean((10.2, registry.kilowatt_hour))
     assert 10.2 * registry.watt_hour == f.clean(10.2 * registry.watt_hour)
Ejemplo n.º 2
0
 def test_floatfield_1(self):
     f = FloatField('kWh')
     self.assertRaises(ValidationError, f.clean, None)
     self.assertRaises(ValidationError, f.clean, 10.2 * registry.meter)
     self.assertRaises(ValidationError, f.clean, 'abc')
     self.assertEqual(10.2 * registry.kilowatt_hour,
                      f.clean(10.2 * registry.kilowatt_hour))
     self.assertEqual(10.2 * registry['kWh'], f.clean(10.2))
     self.assertEqual(10.2 * registry['kWh'], f.clean((10.2, 'kWh')))
     self.assertEqual(10.2 * registry['kWh'],
                      f.clean((10.2, registry.kilowatt_hour)))
     self.assertEqual(10.2 * registry.watt_hour,
                      f.clean(10.2 * registry.watt_hour))
Ejemplo n.º 3
0
 def test_floatfield_1(self):
     f = FloatField('kWh')
     self.assertRaises(ValidationError, f.clean, None)
     self.assertRaises(ValidationError, f.clean, 10.2 * registry.meter)
     self.assertRaises(ValidationError, f.clean, 'abc')
     self.assertEqual(10.2 * registry.kilowatt_hour, f.clean(10.2 * registry.kilowatt_hour))
     self.assertEqual(10.2 * registry['kWh'], f.clean(10.2))
     self.assertEqual(10.2 * registry['kWh'], f.clean((10.2, 'kWh')))
     self.assertEqual(10.2 * registry['kWh'], f.clean((10.2, registry.kilowatt_hour)))
     self.assertEqual(10.2 * registry.watt_hour, f.clean(10.2 * registry.watt_hour))