def test_unit_parser_only_units(self): for bad_name in ['copy', 'math', '__id__', '__doc__', '__builtin__', 'Exception']: self.assertRaises( UnableToParseUnits, unit_parser.parse_unit, bad_name, suppress_unknown=False, ) # But plain numbers like the SI prefixes are kept. for good_name in ['hecto', 'yotta']: self.assertTrue(is_dimensionless( unit_parser.parse_unit(good_name, suppress_unknown=False)))
def test_unit_parser_dimensionless(self): dless = Quantity(1.0, units="", family_name="unknown") self.assert_(is_dimensionless(dless.units), "Dimensionless units not properly parsed")
def test_unit_parser_dimensionless(self): for label in ['', 'None', 'none', 'unknown', 'unitless']: dless = unit_parser.parse_unit(label, suppress_unknown=False) self.assertTrue(is_dimensionless(dless)) self.assertEqual(dless.value, 1)