def test_mul(self): i = self.instance expected = Quantity(2 * i.amount, i.unit) result = 2 * i self.assertEqual(expected, result) result = i * 2 self.assertEqual(expected, result)
def setUpClass(cls): cls.instance = Ingredient.parse('(16 fl oz) distilled water') cls.label = 'distilled water' cls.quantity = Quantity(16, 'fl oz')
def setUpClass(cls): cls.instance = Ingredient.parse('(2) eggs') cls.label = 'eggs' cls.quantity = Quantity(2)
def setUpClass(cls): cls.instance = Quantity.parse('1 1/2 fl oz') cls.amount = Fraction(3, 2) cls.unit = 'fl oz'
def setUpClass(cls): cls.instance = Quantity.parse('1.5 fl oz') cls.amount = 1.5 cls.unit = 'fl oz'
def setUpClass(cls): cls.instance = Quantity.parse('1') cls.amount = 1 cls.unit = None
def setUpClass(cls): cls.instance = Quantity.parse('1 1/2 fl oz') cls.amount = Fraction(3,2) cls.unit = 'fl oz'