diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/api/testing.rst | 4 | ||||
| -rw-r--r-- | docs/narr/unittesting.rst | 13 | ||||
| -rw-r--r-- | docs/tutorials/bfgwiki2/src/authorization/tutorial/tests.py | 12 | ||||
| -rw-r--r-- | docs/tutorials/bfgwiki2/src/views/tutorial/tests.py | 12 |
4 files changed, 35 insertions, 6 deletions
diff --git a/docs/api/testing.rst b/docs/api/testing.rst index f64d78337..94c231459 100644 --- a/docs/api/testing.rst +++ b/docs/api/testing.rst @@ -25,6 +25,10 @@ .. autofunction:: registerRoute + .. autofunction:: setUp + + .. autofunction:: tearDown + .. autofunction:: cleanUp .. autoclass:: DummyModel diff --git a/docs/narr/unittesting.rst b/docs/narr/unittesting.rst index 064be4739..885d7be36 100644 --- a/docs/narr/unittesting.rst +++ b/docs/narr/unittesting.rst @@ -50,10 +50,10 @@ unittest TestCase that used the testing API. class MyTest(unittest.TestCase): def setUp(self): - testing.cleanUp() + testing.setUp() def tearDown(self): - testing.cleanUp() + testing.tearDown() def test_view_fn_not_submitted(self): from my.package import view_fn @@ -105,11 +105,12 @@ assertion. We assert at the end of this that the renderer's ``say`` attribute is ``Yo``, as this is what is expected of the view function in the branch it's testing. -Note that the test calls the ``repoze.bfg.testing.cleanUp`` function -in its ``setUp`` and ``tearDown`` functions. This is required to +Note that the test calls the ``repoze.bfg.testing.setUp`` function in +its ``setUp`` method and the ``repoze.bfg.testing.tearDown`` function +in its ``tearDown`` method. Use of this pattern is required to perform cleanup between the test runs. If you use any of the testing -API, be sure to call this function at setup and teardown of individual -tests. +API, be sure to call ``repoze.bfg.testing.setUp`` in the test setup +and ``repoze.bfg.testing.tearDown`` in the test teardown. See the :ref:`testing_module` chapter for the entire :mod:`repoze.bfg` -specific testing API. This chapter describes APIs for registering a diff --git a/docs/tutorials/bfgwiki2/src/authorization/tutorial/tests.py b/docs/tutorials/bfgwiki2/src/authorization/tutorial/tests.py index 2a1d43749..52d2fed86 100644 --- a/docs/tutorials/bfgwiki2/src/authorization/tutorial/tests.py +++ b/docs/tutorials/bfgwiki2/src/authorization/tutorial/tests.py @@ -17,6 +17,12 @@ def _registerRoutes(): testing.registerRoute('add_page/:pagename', 'add_page') class ViewWikiTests(unittest.TestCase): + def setUp(self): + testing.setUp() + + def tearDown(self): + testing.tearDown() + def test_it(self): from tutorial.views import view_wiki testing.registerRoute(':pagename', 'view_page') @@ -27,9 +33,11 @@ class ViewWikiTests(unittest.TestCase): class ViewPageTests(unittest.TestCase): def setUp(self): self.session = _initTestingDB() + testing.setUp() def tearDown(self): self.session.remove() + testing.tearDown() def _callFUT(self, request): from tutorial.views import view_page @@ -59,9 +67,11 @@ class ViewPageTests(unittest.TestCase): class AddPageTests(unittest.TestCase): def setUp(self): self.session = _initTestingDB() + testing.setUp() def tearDown(self): self.session.remove() + testing.tearDown() def _callFUT(self, request): from tutorial.views import add_page @@ -89,9 +99,11 @@ class AddPageTests(unittest.TestCase): class EditPageTests(unittest.TestCase): def setUp(self): self.session = _initTestingDB() + testing.setUp() def tearDown(self): self.session.remove() + testing.tearDown() def _callFUT(self, request): from tutorial.views import edit_page diff --git a/docs/tutorials/bfgwiki2/src/views/tutorial/tests.py b/docs/tutorials/bfgwiki2/src/views/tutorial/tests.py index 2a1d43749..52d2fed86 100644 --- a/docs/tutorials/bfgwiki2/src/views/tutorial/tests.py +++ b/docs/tutorials/bfgwiki2/src/views/tutorial/tests.py @@ -17,6 +17,12 @@ def _registerRoutes(): testing.registerRoute('add_page/:pagename', 'add_page') class ViewWikiTests(unittest.TestCase): + def setUp(self): + testing.setUp() + + def tearDown(self): + testing.tearDown() + def test_it(self): from tutorial.views import view_wiki testing.registerRoute(':pagename', 'view_page') @@ -27,9 +33,11 @@ class ViewWikiTests(unittest.TestCase): class ViewPageTests(unittest.TestCase): def setUp(self): self.session = _initTestingDB() + testing.setUp() def tearDown(self): self.session.remove() + testing.tearDown() def _callFUT(self, request): from tutorial.views import view_page @@ -59,9 +67,11 @@ class ViewPageTests(unittest.TestCase): class AddPageTests(unittest.TestCase): def setUp(self): self.session = _initTestingDB() + testing.setUp() def tearDown(self): self.session.remove() + testing.tearDown() def _callFUT(self, request): from tutorial.views import add_page @@ -89,9 +99,11 @@ class AddPageTests(unittest.TestCase): class EditPageTests(unittest.TestCase): def setUp(self): self.session = _initTestingDB() + testing.setUp() def tearDown(self): self.session.remove() + testing.tearDown() def _callFUT(self, request): from tutorial.views import edit_page |
