mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-02 01:35:40 +08:00
ENH: Include choices in no-output-found errormsg.
This commit is contained in:
@@ -457,14 +457,16 @@ class ObjectIdentityTestCase(TestCase):
|
||||
errmsg, "'SomeFactor' object has no attribute 'not_an_attr'",
|
||||
)
|
||||
|
||||
mo = MultipleOutputs()
|
||||
with self.assertRaises(AttributeError) as e:
|
||||
MultipleOutputs().not_an_attr
|
||||
mo.not_an_attr
|
||||
|
||||
errmsg = str(e.exception)
|
||||
self.assertEqual(
|
||||
errmsg,
|
||||
"Instance of MultipleOutputs has no output called 'not_an_attr'.",
|
||||
expected = (
|
||||
"Instance of MultipleOutputs has no output named 'not_an_attr'."
|
||||
" Possible choices are: ('alpha', 'beta')."
|
||||
)
|
||||
self.assertEqual(errmsg, expected)
|
||||
|
||||
with self.assertRaises(ValueError) as e:
|
||||
alpha, beta = GenericCustomFactor()
|
||||
|
||||
@@ -1209,8 +1209,11 @@ class CustomFactor(PositiveWindowLengthMixin, CustomTermMixin, Factor):
|
||||
return RecarrayField(factor=self, attribute=attribute_name)
|
||||
else:
|
||||
raise AttributeError(
|
||||
'Instance of {factor} has no output called {attr!r}.'.format(
|
||||
factor=type(self).__name__, attr=attribute_name,
|
||||
'Instance of {factor} has no output named {attr!r}.'
|
||||
' Possible choices are: {choices}.'.format(
|
||||
factor=type(self).__name__,
|
||||
attr=attribute_name,
|
||||
choices=self.outputs,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user