From c60c3106c700f5f42ad4fcf82f327da98ec5eb9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Barrois?= Date: Thu, 12 Jan 2012 23:21:38 +0100 Subject: Add __repr__ / __str__ to a couple of objects. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Raphaƫl Barrois --- factory/containers.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'factory/containers.py') diff --git a/factory/containers.py b/factory/containers.py index 497e98c..dd11f5f 100644 --- a/factory/containers.py +++ b/factory/containers.py @@ -49,13 +49,21 @@ class LazyStub(object): __initialized = False - def __init__(self, attrs, containers=()): + def __init__(self, attrs, containers=(), target_class=object): self.__attrs = attrs self.__values = {} self.__pending = [] self.__containers = containers + self.__target_class = target_class self.__initialized = True + def __repr__(self): + return '' % self.__target_class.__name__ + + def __str__(self): + return '' % ( + self.__target_class.__name__, self.__attrs.keys()) + def __fill__(self): """Fill this LazyStub, computing values of all defined attributes. @@ -258,7 +266,9 @@ class AttributeBuilder(object): v = OrderedDeclarationWrapper(v, self.factory.sequence) wrapped_attrs[k] = v - return LazyStub(wrapped_attrs, containers=self._containers).__fill__() + stub = LazyStub(wrapped_attrs, containers=self._containers, + target_class=self.factory) + return stub.__fill__() class StubObject(object): -- cgit v1.2.3