summaryrefslogtreecommitdiff
path: root/repoze/bfg/tests/test_testing.py
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2008-11-10 00:05:48 +0000
committerChris McDonough <chrism@agendaless.com>2008-11-10 00:05:48 +0000
commit6a79148f646fa474c962a5a7323554963c45177b (patch)
tree81bd237ce79b2f349a90b5ac123969ef39e35b6a /repoze/bfg/tests/test_testing.py
parent747cd4e494285c1297953d76c33278feb622efca (diff)
downloadpyramid-6a79148f646fa474c962a5a7323554963c45177b.tar.gz
pyramid-6a79148f646fa474c962a5a7323554963c45177b.tar.bz2
pyramid-6a79148f646fa474c962a5a7323554963c45177b.zip
Features
- Added a ``clone`` method and a ``__contains__`` method to the DummyModel testing object. - Allow DummyModel objects to receive extra keyword arguments, which will be attached as attributes. - The DummyTemplateRenderer now returns ``self`` as its implementation.
Diffstat (limited to 'repoze/bfg/tests/test_testing.py')
-rw-r--r--repoze/bfg/tests/test_testing.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/repoze/bfg/tests/test_testing.py b/repoze/bfg/tests/test_testing.py
index 5ef66e759..abd955c96 100644
--- a/repoze/bfg/tests/test_testing.py
+++ b/repoze/bfg/tests/test_testing.py
@@ -266,9 +266,9 @@ class TestDummyModel(unittest.TestCase):
from repoze.bfg.testing import DummyModel
return DummyModel
- def _makeOne(self, name=None, parent=None):
+ def _makeOne(self, name=None, parent=None, **kw):
klass = self._getTargetClass()
- return klass(name, parent)
+ return klass(name, parent, **kw)
def test__setitem__and__getitem__(self):
class Dummy:
@@ -281,6 +281,18 @@ class TestDummyModel(unittest.TestCase):
self.assertEqual(model['abc'], dummy)
self.assertRaises(KeyError, model.__getitem__, 'none')
+ def test_extra_params(self):
+ model = self._makeOne(foo=1)
+ self.assertEqual(model.foo, 1)
+
+ def test_clone(self):
+ model = self._makeOne('name', 'parent', foo=1, bar=2)
+ clone = model.clone('name2', 'parent2', bar=1)
+ self.assertEqual(clone.bar, 1)
+ self.assertEqual(clone.__name__, 'name2')
+ self.assertEqual(clone.__parent__, 'parent2')
+ self.assertEqual(clone.foo, 1)
+
class TestDummyRequest(unittest.TestCase):
def _getTargetClass(self):
from repoze.bfg.testing import DummyRequest