From 6a79148f646fa474c962a5a7323554963c45177b Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Mon, 10 Nov 2008 00:05:48 +0000 Subject: 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. --- repoze/bfg/tests/test_testing.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'repoze/bfg/tests/test_testing.py') 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 -- cgit v1.2.3