Пример #1
0
 def testConstructor_003(self):
     """
     Test assignment of quantity attribute, None value.
     """
     quantity = PercentageQuantity(quantity="1.0")
     self.assertEqual("1.0", quantity.quantity)
     self.assertEqual(1.0, quantity.percentage)
     quantity.quantity = None
     self.assertEqual(None, quantity.quantity)
     self.assertEqual(0.0, quantity.percentage)
Пример #2
0
 def testConstructor_004(self):
     """
     Test assignment of quantity attribute, valid values.
     """
     quantity = PercentageQuantity()
     self.assertEqual(None, quantity.quantity)
     self.assertEqual(0.0, quantity.percentage)
     quantity.quantity = "1.0"
     self.assertEqual("1.0", quantity.quantity)
     self.assertEqual(1.0, quantity.percentage)
     quantity.quantity = ".1"
     self.assertEqual(".1", quantity.quantity)
     self.assertEqual(0.1, quantity.percentage)
     quantity.quantity = "12"
     self.assertEqual("12", quantity.quantity)
     self.assertEqual(12.0, quantity.percentage)
     quantity.quantity = "0.5"
     self.assertEqual("0.5", quantity.quantity)
     self.assertEqual(0.5, quantity.percentage)
     quantity.quantity = "0.25E2"
     self.assertEqual("0.25E2", quantity.quantity)
     self.assertEqual(0.25e2, quantity.percentage)