summaryrefslogtreecommitdiff
path: root/docs/tutorials/wiki/src/models/tests
diff options
context:
space:
mode:
authorSteve Piercy <web@stevepiercy.com>2021-01-09 04:56:15 -0800
committerSteve Piercy <web@stevepiercy.com>2021-01-09 04:56:15 -0800
commit0235bd17c7a02cbdb833f57f1af7a0deeec9b8b4 (patch)
tree59c32a6c3cbb9e3c92e629a39f06f7abc3e3648e /docs/tutorials/wiki/src/models/tests
parent16d66c801d20010036d2d89e2f20e4156e19aa3e (diff)
downloadpyramid-0235bd17c7a02cbdb833f57f1af7a0deeec9b8b4.tar.gz
pyramid-0235bd17c7a02cbdb833f57f1af7a0deeec9b8b4.tar.bz2
pyramid-0235bd17c7a02cbdb833f57f1af7a0deeec9b8b4.zip
Update conftest.py, pytest.ini, and README.txt for all steps where needed
Diffstat (limited to 'docs/tutorials/wiki/src/models/tests')
-rw-r--r--docs/tutorials/wiki/src/models/tests/conftest.py34
1 files changed, 20 insertions, 14 deletions
diff --git a/docs/tutorials/wiki/src/models/tests/conftest.py b/docs/tutorials/wiki/src/models/tests/conftest.py
index 6a702ae12..86793408d 100644
--- a/docs/tutorials/wiki/src/models/tests/conftest.py
+++ b/docs/tutorials/wiki/src/models/tests/conftest.py
@@ -1,7 +1,7 @@
import os
from pyramid.paster import get_appsettings
from pyramid.scripting import prepare
-from pyramid.testing import DummyRequest
+from pyramid.testing import DummyRequest, testConfig
import pytest
import transaction
import webtest
@@ -54,31 +54,37 @@ def app_request(app, tm):
drawbacks in tests as it's harder to mock data and is heavier.
"""
- env = prepare(registry=app.registry)
- request = env['request']
- request.host = 'example.com'
- request.tm = tm
-
- yield request
- env['closer']()
+ with prepare(registry=app.registry) as env:
+ request = env['request']
+ request.host = 'example.com'
+ yield request
@pytest.fixture
-def dummy_request(app, tm):
+def dummy_request(tm):
"""
A lightweight dummy request.
- This request is ultra-lightweight and should be used only when the
- request itself is not a large focus in the call-stack.
-
- It is way easier to mock and control side-effects using this object.
+ This request is ultra-lightweight and should be used only when the request
+ itself is not a large focus in the call-stack. It is much easier to mock
+ and control side-effects using this object, however:
- It does not have request extensions applied.
- Threadlocals are not properly pushed.
"""
request = DummyRequest()
- request.registry = app.registry
request.host = 'example.com'
request.tm = tm
return request
+
+@pytest.fixture
+def dummy_config(dummy_request):
+ """
+ A dummy :class:`pyramid.config.Configurator` object. This allows for
+ mock configuration, including configuration for ``dummy_request``, as well
+ as pushing the appropriate threadlocals.
+
+ """
+ with testConfig(request=dummy_request) as config:
+ yield config