summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/api/testing.rst4
-rw-r--r--docs/narr/MyProject/myproject/tests.py2
-rw-r--r--docs/narr/unittesting.rst9
3 files changed, 11 insertions, 4 deletions
diff --git a/docs/api/testing.rst b/docs/api/testing.rst
index 51b017fbf..9aebc7d30 100644
--- a/docs/api/testing.rst
+++ b/docs/api/testing.rst
@@ -23,4 +23,8 @@
.. autoclass:: DummyRequest
:members:
+ .. autoclass:: DummyTemplateRenderer
+ :members:
+
+
diff --git a/docs/narr/MyProject/myproject/tests.py b/docs/narr/MyProject/myproject/tests.py
index 4c2f6a9ec..64314616d 100644
--- a/docs/narr/MyProject/myproject/tests.py
+++ b/docs/narr/MyProject/myproject/tests.py
@@ -28,7 +28,7 @@ class ViewTests(unittest.TestCase):
request = testing.DummyRequest()
renderer = testing.registerDummyRenderer('templates/mytemplate.pt')
response = my_view(context, request)
- self.assertEqual(renderer.project, 'myproject')
+ renderer.assert_(project='myproject')
class ViewIntegrationTests(unittest.TestCase):
""" These tests are integration tests for the view. These test
diff --git a/docs/narr/unittesting.rst b/docs/narr/unittesting.rst
index 165e92411..34a0740e9 100644
--- a/docs/narr/unittesting.rst
+++ b/docs/narr/unittesting.rst
@@ -62,7 +62,7 @@ unittest TestCase that used the testing API.
context = testing.DummyModel()
request = testing.DummyRequest()
response = view_fn(context, request)
- self.assertEqual(renderer.say, 'Hello')
+ renderer.assert_(say='Hello')
def test_view_fn_submitted(self):
from my.package import view_fn
@@ -71,7 +71,7 @@ unittest TestCase that used the testing API.
request = testing.DummyRequest()
request.params['say'] = 'Yo'
response = view_fn(context, request)
- self.assertEqual(renderer.say, 'Yo')
+ renderer.assert_(say='Yo')
In the above example, we create a ``MyTest`` test case that inherits
from ``unittest.TestCase``. If it's in our :mod:`repoze.bfg`
@@ -94,7 +94,10 @@ the dummy renderer is called, it will set attributes on itself
corresponding to the non-path keyword arguments provided to the
``render_template_to_response`` function. We check that the ``say``
parameter sent into the template rendering function was ``Hello`` in
-this specific example.
+this specific example. The ``assert_`` method of the renderer we've
+created will raise an ``AssertionError`` if the value passed to the
+renderer as ``say`` does not equal ``Hello`` (any number of keyword
+arguments are supported).
The second test method, named ``test_view_fn_submitted`` tests the
alternate case, where the ``say`` form value has already been set in