summaryrefslogtreecommitdiff
path: root/test/test_templite.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2009-05-05 07:00:19 -0400
committerNed Batchelder <ned@nedbatchelder.com>2009-05-05 07:00:19 -0400
commit7ee3eed7c36bce6673e2d07afe80a157b8ff2f56 (patch)
tree10a4a801b30692e59df97d34f1e4d531d0431def /test/test_templite.py
parent85e43adf3dcc94566b27164bd7a9cb8e456fe4bd (diff)
downloadpython-coveragepy-7ee3eed7c36bce6673e2d07afe80a157b8ff2f56.tar.gz
Lint clean-ups.
Diffstat (limited to 'test/test_templite.py')
-rw-r--r--test/test_templite.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/test/test_templite.py b/test/test_templite.py
index fd7a339..436951a 100644
--- a/test/test_templite.py
+++ b/test/test_templite.py
@@ -3,8 +3,16 @@
from coverage.templite import Templite
import unittest
-class AnyOldObject:
- pass
+class AnyOldObject(object):
+ """Simple testing object.
+
+ Use keyword arguments in the constructor to set attributes on the object.
+
+ """
+ def __init__(self, **attrs):
+ for n, v in attrs.items():
+ setattr(self, n, v)
+
class TemplateTest(unittest.TestCase):
@@ -48,18 +56,15 @@ class TemplateTest(unittest.TestCase):
def test_attribute(self):
# Variables' attributes can be accessed with dots.
- obj = AnyOldObject()
- obj.a = "Ay"
+ obj = AnyOldObject(a="Ay")
self.try_render("{{obj.a}}", locals(), "Ay")
- obj2 = AnyOldObject()
- obj2.obj = obj
- obj2.b = "Bee"
+ obj2 = AnyOldObject(obj=obj, b="Bee")
self.try_render("{{obj2.obj.a}} {{obj2.b}}", locals(), "Ay Bee")
def test_member_function(self):
# Variables' member functions can be used, as long as they are nullary.
- class WithMemberFns:
+ class WithMemberFns(object):
def ditto(self):
return self.txt + self.txt
obj = WithMemberFns()