def test_fixed(self): field5 = fields.Fixed(5) field4 = fields.Fixed(4) self.assertEquals('3.14159', field5.output("hey", {'hey': self.PI})) self.assertEquals('3.1416', field4.output("hey", {'hey': self.PI})) self.assertEquals('3.0000', field4.output("hey", {'hey': '3'})) self.assertEquals('3.0000', field4.output("hey", {'hey': '03'})) self.assertEquals('3.0000', field4.output("hey", {'hey': '03.0'}))
def test_fixed_with_attribute(self): field = fields.Fixed(4, attribute="bar") self.assertEquals('3.0000', field.output("foo", {'bar': '3'}))
def test_advanced_fixed(self): field = fields.Fixed() self.assertRaises(MarshallingException, lambda: field.output("hey", {'hey': 'NaN'}))
def test_infinite_fixed(self): field = fields.Fixed() self.assertRaises(MarshallingException, lambda: field.output("hey", {'hey': '+inf'})) self.assertRaises(MarshallingException, lambda: field.output("hey", {'hey': '-inf'}))
def test_zero_fixed(self): field = fields.Fixed() self.assertEquals('0.00000', field.output('hey', {'hey': 0}))