diff --git a/tests/pipeline/test_term.py b/tests/pipeline/test_term.py index 062bd9e4..35d7528d 100644 --- a/tests/pipeline/test_term.py +++ b/tests/pipeline/test_term.py @@ -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() diff --git a/zipline/pipeline/factors/factor.py b/zipline/pipeline/factors/factor.py index 6a0b0b08..b14a4a0f 100644 --- a/zipline/pipeline/factors/factor.py +++ b/zipline/pipeline/factors/factor.py @@ -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, ) )