diff options
| author | Michael Merickel <michael@merickel.org> | 2020-01-12 15:46:10 -0600 |
|---|---|---|
| committer | Michael Merickel <michael@merickel.org> | 2020-01-12 15:46:10 -0600 |
| commit | 3c484c3333672a7ed60436e14cd731458f7bd5e6 (patch) | |
| tree | 3856321567dceee45f546d93180ef29842f00537 /docs/tutorials/wiki/src/models/tests | |
| parent | 3e38f884549658c41e8698a55cad0b8b3729333f (diff) | |
| download | pyramid-3c484c3333672a7ed60436e14cd731458f7bd5e6.tar.gz pyramid-3c484c3333672a7ed60436e14cd731458f7bd5e6.tar.bz2 pyramid-3c484c3333672a7ed60436e14cd731458f7bd5e6.zip | |
re-sync changes to starter conftest
Diffstat (limited to 'docs/tutorials/wiki/src/models/tests')
| -rw-r--r-- | docs/tutorials/wiki/src/models/tests/conftest.py | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/docs/tutorials/wiki/src/models/tests/conftest.py b/docs/tutorials/wiki/src/models/tests/conftest.py index 12e75d8e9..6a702ae12 100644 --- a/docs/tutorials/wiki/src/models/tests/conftest.py +++ b/docs/tutorials/wiki/src/models/tests/conftest.py @@ -3,6 +3,7 @@ from pyramid.paster import get_appsettings from pyramid.scripting import prepare from pyramid.testing import DummyRequest import pytest +import transaction import webtest from tutorial import main @@ -25,15 +26,27 @@ def app(app_settings): return main({}, **app_settings) @pytest.fixture -def testapp(app): +def tm(): + tm = transaction.manager + tm.begin() + tm.doom() + + yield tm + + tm.abort() + +@pytest.fixture +def testapp(app, tm): testapp = webtest.TestApp(app, extra_environ={ 'HTTP_HOST': 'example.com', + 'tm.active': True, + 'tm.manager': tm, }) return testapp @pytest.fixture -def app_request(app): +def app_request(app, tm): """ A real request. @@ -44,12 +57,13 @@ def app_request(app): env = prepare(registry=app.registry) request = env['request'] request.host = 'example.com' + request.tm = tm yield request env['closer']() @pytest.fixture -def dummy_request(app): +def dummy_request(app, tm): """ A lightweight dummy request. @@ -65,5 +79,6 @@ def dummy_request(app): request = DummyRequest() request.registry = app.registry request.host = 'example.com' + request.tm = tm return request |
