summaryrefslogtreecommitdiff
path: root/pystache
diff options
context:
space:
mode:
authorRodrigo Bernardo Pimentel <rbp@isnomore.net>2012-04-29 18:16:53 +0200
committerRodrigo Bernardo Pimentel <rbp@isnomore.net>2012-04-29 18:16:53 +0200
commit8180ef7a331677f3a8975c14fc73c099a174a3e9 (patch)
tree35186673f01f9a32098fc47d1ea7b5d12a8cd97b /pystache
parent012bdba1d29c37c3b0bbdd889ab7f6717c649856 (diff)
downloadpystache-8180ef7a331677f3a8975c14fc73c099a174a3e9.tar.gz
Moving Attachable helper class into the correct module
Diffstat (limited to 'pystache')
-rw-r--r--pystache/tests/common.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/pystache/tests/common.py b/pystache/tests/common.py
index a99e709..12601e9 100644
--- a/pystache/tests/common.py
+++ b/pystache/tests/common.py
@@ -191,3 +191,22 @@ class SetupDefaults(object):
defaults.FILE_ENCODING = self.original_file_encoding
defaults.STRING_ENCODING = self.original_string_encoding
+
+class Attachable(object):
+ """A trivial object that attaches all constructor named parameters as attributes.
+ For instance,
+
+ >>> o = Attachable(foo=42, size="of the universe")
+ >>> o.foo
+ 42
+ >>> o.size
+ of the universe
+ """
+ def __init__(self, **kwargs):
+ self.__args__ = kwargs
+ for arg, value in kwargs.iteritems():
+ setattr(self, arg, value)
+
+ def __repr__(self):
+ return "A(%s)" % (", ".join("%s=%s" % (k, v)
+ for k, v in self.__args__.iteritems()))