summaryrefslogtreecommitdiff
path: root/docs/narr/testing.rst
diff options
context:
space:
mode:
authorMichael Merickel <michael@merickel.org>2020-01-16 10:09:45 -0600
committerMichael Merickel <michael@merickel.org>2020-01-16 10:09:45 -0600
commita7f61dc1ae95ffddacccfb583fa7a8f6d294f4b9 (patch)
tree8aca99052f7086bcb37609b516d7a11902377d71 /docs/narr/testing.rst
parenteb7046c8eeb8c9b598260ae8c8976187a8f84953 (diff)
parent9c153e1250e00faa06003c10c3a26886489e6210 (diff)
downloadpyramid-a7f61dc1ae95ffddacccfb583fa7a8f6d294f4b9.tar.gz
pyramid-a7f61dc1ae95ffddacccfb583fa7a8f6d294f4b9.tar.bz2
pyramid-a7f61dc1ae95ffddacccfb583fa7a8f6d294f4b9.zip
Merge branch 'master' into move-acl-security-to-authorization
Diffstat (limited to 'docs/narr/testing.rst')
-rw-r--r--docs/narr/testing.rst23
1 files changed, 15 insertions, 8 deletions
diff --git a/docs/narr/testing.rst b/docs/narr/testing.rst
index 0fa1e98fd..bb23d5137 100644
--- a/docs/narr/testing.rst
+++ b/docs/narr/testing.rst
@@ -395,23 +395,30 @@ As always, whenever you change your dependencies, make sure to run the correct
$VENV/bin/pip install -e ".[testing]"
-In your ``MyPackage`` project, your :term:`package` is named ``myproject``
+In your ``myproject`` project, your :term:`package` is named ``myproject``
which contains a ``views`` package containing a ``default.py`` module, which in turn contains a :term:`view`
function ``my_view`` that returns an HTML body when the root URL is invoked:
- .. literalinclude:: myproject/myproject/views/default.py
- :linenos:
- :language: python
+ .. literalinclude:: myproject/myproject/views/default.py
+ :linenos:
+ :language: python
+
+Test configuration and fixtures are defined in ``conftest.py``.
+In the following example, we define a test fixture.
+
+ .. literalinclude:: myproject/tests/conftest.py
+ :pyobject: testapp
+ :linenos:
+ :language: python
-The following example functional tests demonstrate invoking the above :term:`view`:
+This fixture is used in the following example functional tests, to demonstrate invoking the above :term:`view`:
- .. literalinclude:: myproject/tests/test_it.py
+ .. literalinclude:: myproject/tests/test_functional.py
:linenos:
- :pyobject: FunctionalTests
:language: python
When these tests are run, each test method creates a "real" :term:`WSGI` application using the ``main`` function in your ``myproject.__init__`` module, using :term:`WebTest` to wrap that WSGI application.
-It assigns the result to ``self.testapp``.
+It assigns the result to ``res``.
In the test named ``test_root``, the ``TestApp``'s ``GET`` method is used to invoke the root URL.
An assertion is made that the returned HTML contains the text ``Pyramid``.