Пример #1
0
    def test_non_value(self):
        # A string that isn't a unit declaration
        with self.assertRaises(ValueError):
            parser.units('hello')

        # Check a value that ends with a valid unit
        with self.assertRaises(ValueError):
            parser.units('church')
Пример #2
0
 def assertEqualUnits(self, value, expected):
     # Nothing fancy - a unit is equal if
     # it's the same unit type, with the same value.
     actual = parser.units(value)
     self.assertEqual(actual.suffix, expected.suffix)
     self.assertEqual(actual.val, expected.val)