changed UndefinedUnitError to inherit from AttributeError, so `hasattr` works on unit registry.
This commit is contained in:
parent
de8fdff91b
commit
1cac87cf60
|
@ -49,12 +49,12 @@ class RedefinitionError(ValueError):
|
|||
return msg
|
||||
|
||||
|
||||
class UndefinedUnitError(ValueError):
|
||||
class UndefinedUnitError(AttributeError):
|
||||
"""Raised when the units are not defined in the unit registry.
|
||||
"""
|
||||
|
||||
def __init__(self, unit_names):
|
||||
super(ValueError, self).__init__()
|
||||
super(UndefinedUnitError, self).__init__()
|
||||
self.unit_names = unit_names
|
||||
|
||||
def __str__(self):
|
||||
|
|
|
@ -234,7 +234,7 @@ class TestIssues(QuantityTestCase):
|
|||
|
||||
for func in (ureg.get_name, ureg.parse_expression):
|
||||
val = func('meter')
|
||||
self.assertRaises(ValueError, func, 'METER')
|
||||
self.assertRaises(AttributeError, func, 'METER')
|
||||
self.assertEqual(val, func('METER', False))
|
||||
|
||||
def test_issue104(self):
|
||||
|
|
Loading…
Reference in New Issue