Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions factory/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,9 @@ def __getattr__(self, name):
return value
else:
raise AttributeError(
"The parameter %r is unknown. Evaluated attributes are %r, "
"definitions are %r." % (name, self.__values, self.__declarations))
"The parameter %r is unknown. Available attributes are: %s."
% (name, ", ".join(list(self.__declarations)))
)

def __setattr__(self, name, value):
"""Prevent setting attributes once __init__ is done."""
Expand Down
7 changes: 6 additions & 1 deletion tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,14 @@ class Meta:
model = TestObject

one = declarations.LazyAttribute(lambda a: a.does_not_exist)
two = 2

with self.assertRaises(AttributeError):
with self.assertRaises(AttributeError) as exc:
TestObjectFactory()
self.assertEqual(
str(exc.exception),
"The parameter 'does_not_exist' is unknown. Available attributes are: one, two.",
)

def test_inheritance_with_sequence(self):
"""Tests that sequence IDs are shared between parent and son."""
Expand Down