diff options
Diffstat (limited to 'repoze/bfg/tests')
| -rw-r--r-- | repoze/bfg/tests/test_chameleon_text.py | 7 | ||||
| -rw-r--r-- | repoze/bfg/tests/test_chameleon_zpt.py | 7 | ||||
| -rw-r--r-- | repoze/bfg/tests/test_decorator.py | 23 |
3 files changed, 37 insertions, 0 deletions
diff --git a/repoze/bfg/tests/test_chameleon_text.py b/repoze/bfg/tests/test_chameleon_text.py index 54ffc8b10..007c102e3 100644 --- a/repoze/bfg/tests/test_chameleon_text.py +++ b/repoze/bfg/tests/test_chameleon_text.py @@ -47,6 +47,13 @@ class TextTemplateRendererTests(Base, unittest.TestCase): from repoze.bfg.interfaces import ITemplateRenderer verifyClass(ITemplateRenderer, self._getTargetClass()) + def test_template_reified(self): + minimal = self._getTemplatePath('minimal.txt') + instance = self._makeOne(minimal) + self.failIf('template' in instance.__dict__) + template = instance.template + self.assertEqual(template, instance.__dict__['template']) + def test_call(self): minimal = self._getTemplatePath('minimal.txt') instance = self._makeOne(minimal) diff --git a/repoze/bfg/tests/test_chameleon_zpt.py b/repoze/bfg/tests/test_chameleon_zpt.py index 38ef543cf..e4bf8f766 100644 --- a/repoze/bfg/tests/test_chameleon_zpt.py +++ b/repoze/bfg/tests/test_chameleon_zpt.py @@ -48,6 +48,13 @@ class ZPTTemplateRendererTests(Base, unittest.TestCase): self.assertEqual(result, '<div xmlns="http://www.w3.org/1999/xhtml">\n</div>') + def test_template_reified(self): + minimal = self._getTemplatePath('minimal.pt') + instance = self._makeOne(minimal) + self.failIf('template' in instance.__dict__) + template = instance.template + self.assertEqual(template, instance.__dict__['template']) + def test_call_with_nondict_value(self): minimal = self._getTemplatePath('minimal.pt') instance = self._makeOne(minimal) diff --git a/repoze/bfg/tests/test_decorator.py b/repoze/bfg/tests/test_decorator.py new file mode 100644 index 000000000..b1ac2252d --- /dev/null +++ b/repoze/bfg/tests/test_decorator.py @@ -0,0 +1,23 @@ +import unittest + +class TestReify(unittest.TestCase): + def _makeOne(self, wrapped): + from repoze.bfg.decorator import reify + return reify(wrapped) + + def test___get__withinst(self): + def wrapped(inst): + return 'a' + decorator = self._makeOne(wrapped) + inst = Dummy() + result = decorator.__get__(inst) + self.assertEqual(result, 'a') + self.assertEqual(inst.__dict__['wrapped'], 'a') + + def test___get__noinst(self): + decorator = self._makeOne(None) + result = decorator.__get__(None) + self.assertEqual(result, decorator) + +class Dummy(object): + pass |
