diff options
| author | Theron Luhn <theron@luhn.com> | 2020-11-11 21:44:05 -0800 |
|---|---|---|
| committer | Theron Luhn <theron@luhn.com> | 2020-11-11 21:44:05 -0800 |
| commit | 7933c51abd4b716aea9199acdc8cc7ec9296d07e (patch) | |
| tree | 4b19186a90775c7cfbd895553afd57c46f708b3b /docs/tutorials/wiki2 | |
| parent | ae2e73dd715403ece419b096737ff8e01dc1a32c (diff) | |
| download | pyramid-7933c51abd4b716aea9199acdc8cc7ec9296d07e.tar.gz pyramid-7933c51abd4b716aea9199acdc8cc7ec9296d07e.tar.bz2 pyramid-7933c51abd4b716aea9199acdc8cc7ec9296d07e.zip | |
Add to test documentation.
Diffstat (limited to 'docs/tutorials/wiki2')
| -rw-r--r-- | docs/tutorials/wiki2/src/tests/tests/conftest.py | 2 | ||||
| -rw-r--r-- | docs/tutorials/wiki2/tests.rst | 7 |
2 files changed, 5 insertions, 4 deletions
diff --git a/docs/tutorials/wiki2/src/tests/tests/conftest.py b/docs/tutorials/wiki2/src/tests/tests/conftest.py index 8882ea265..45d33bb92 100644 --- a/docs/tutorials/wiki2/src/tests/tests/conftest.py +++ b/docs/tutorials/wiki2/src/tests/tests/conftest.py @@ -143,7 +143,6 @@ def app_request(app, tm, dbsession): yield request env['closer']() - @pytest.fixture def dummy_request(tm, dbsession): """ @@ -165,7 +164,6 @@ def dummy_request(tm, dbsession): return request - @pytest.yield_fixture def dummy_config(dummy_request): with testConfig(request=dummy_request) as config: diff --git a/docs/tutorials/wiki2/tests.rst b/docs/tutorials/wiki2/tests.rst index cee7a809d..dce14cf9b 100644 --- a/docs/tutorials/wiki2/tests.rst +++ b/docs/tutorials/wiki2/tests.rst @@ -69,6 +69,9 @@ Per-test fixtures - ``dummy_request`` - a :class:`pyramid.testing.DummyRequest` object that is very lightweight. This is a great object to pass to view functions that have minimal side-effects as it'll be fast and simple. +- ``dummy_config`` — a :class:`pyramid.config.Configurator` object used as configuration by ``dummy_request``. + Useful for mocking configuration like routes and security policies. + Modifying the fixtures ---------------------- @@ -109,8 +112,8 @@ Integration tests ================= We can directly execute the view code, bypassing :app:`Pyramid` and testing just the code that we've written. -These tests use dummy requests that we'll prepare appropriately to set the conditions each view expects. -For example, setting ``request.identity``, or adding some dummy data to the session. +These tests use dummy requests that we'll prepare appropriately to set the conditions each view expects, such as adding dummy data to the session. +We'll be using ``dummy_config`` to configure the necessary routes, as well as setting the security policy as :class:`pyramid.testing.DummySecurityPolicy` to mock ``dummy_request.identity``. Update ``tests/test_views.py`` such that it appears as follows: |
