Skip to content

Commit

Permalink
Remove app_request from wiki2 tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
luhn committed Nov 12, 2020
1 parent 042a2b9 commit 86cb46d
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 164 deletions.
23 changes: 0 additions & 23 deletions docs/tutorials/wiki2/src/authentication/tests/conftest.py
Expand Up @@ -3,7 +3,6 @@
import alembic.command
import os
from pyramid.paster import get_appsettings
from pyramid.scripting import prepare
from pyramid.testing import DummyRequest, testConfig
import pytest
import transaction
Expand Down Expand Up @@ -80,28 +79,6 @@ def testapp(app, tm, dbsession):

return testapp

@pytest.fixture
def app_request(app, tm, dbsession):
"""
A real request.
This request is almost identical to a real request but it has some
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'

# without this, request.dbsession will be joined to the same transaction
# manager but it will be using a different sqlalchemy.orm.Session using
# a separate database transaction
request.dbsession = dbsession
request.tm = tm

yield request
env['closer']()

@pytest.fixture
def dummy_request(tm, dbsession):
"""
Expand Down
23 changes: 0 additions & 23 deletions docs/tutorials/wiki2/src/authorization/tests/conftest.py
Expand Up @@ -3,7 +3,6 @@
import alembic.command
import os
from pyramid.paster import get_appsettings
from pyramid.scripting import prepare
from pyramid.testing import DummyRequest, testConfig
import pytest
import transaction
Expand Down Expand Up @@ -80,28 +79,6 @@ def testapp(app, tm, dbsession):

return testapp

@pytest.fixture
def app_request(app, tm, dbsession):
"""
A real request.
This request is almost identical to a real request but it has some
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'

# without this, request.dbsession will be joined to the same transaction
# manager but it will be using a different sqlalchemy.orm.Session using
# a separate database transaction
request.dbsession = dbsession
request.tm = tm

yield request
env['closer']()

@pytest.fixture
def dummy_request(tm, dbsession):
"""
Expand Down
23 changes: 0 additions & 23 deletions docs/tutorials/wiki2/src/basiclayout/tests/conftest.py
Expand Up @@ -3,7 +3,6 @@
import alembic.command
import os
from pyramid.paster import get_appsettings
from pyramid.scripting import prepare
from pyramid.testing import DummyRequest, testConfig
import pytest
import transaction
Expand Down Expand Up @@ -80,28 +79,6 @@ def testapp(app, tm, dbsession):

return testapp

@pytest.fixture
def app_request(app, tm, dbsession):
"""
A real request.
This request is almost identical to a real request but it has some
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'

# without this, request.dbsession will be joined to the same transaction
# manager but it will be using a different sqlalchemy.orm.Session using
# a separate database transaction
request.dbsession = dbsession
request.tm = tm

yield request
env['closer']()

@pytest.fixture
def dummy_request(tm, dbsession):
"""
Expand Down
23 changes: 0 additions & 23 deletions docs/tutorials/wiki2/src/installation/tests/conftest.py
Expand Up @@ -3,7 +3,6 @@
import alembic.command
import os
from pyramid.paster import get_appsettings
from pyramid.scripting import prepare
from pyramid.testing import DummyRequest, testConfig
import pytest
import transaction
Expand Down Expand Up @@ -80,28 +79,6 @@ def testapp(app, tm, dbsession):

return testapp

@pytest.fixture
def app_request(app, tm, dbsession):
"""
A real request.
This request is almost identical to a real request but it has some
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'

# without this, request.dbsession will be joined to the same transaction
# manager but it will be using a different sqlalchemy.orm.Session using
# a separate database transaction
request.dbsession = dbsession
request.tm = tm

yield request
env['closer']()

@pytest.fixture
def dummy_request(tm, dbsession):
"""
Expand Down
23 changes: 0 additions & 23 deletions docs/tutorials/wiki2/src/models/tests/conftest.py
Expand Up @@ -3,7 +3,6 @@
import alembic.command
import os
from pyramid.paster import get_appsettings
from pyramid.scripting import prepare
from pyramid.testing import DummyRequest, testConfig
import pytest
import transaction
Expand Down Expand Up @@ -80,28 +79,6 @@ def testapp(app, tm, dbsession):

return testapp

@pytest.fixture
def app_request(app, tm, dbsession):
"""
A real request.
This request is almost identical to a real request but it has some
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'

# without this, request.dbsession will be joined to the same transaction
# manager but it will be using a different sqlalchemy.orm.Session using
# a separate database transaction
request.dbsession = dbsession
request.tm = tm

yield request
env['closer']()

@pytest.fixture
def dummy_request(tm, dbsession):
"""
Expand Down
23 changes: 0 additions & 23 deletions docs/tutorials/wiki2/src/tests/tests/conftest.py
Expand Up @@ -3,7 +3,6 @@
import alembic.command
import os
from pyramid.paster import get_appsettings
from pyramid.scripting import prepare
from pyramid.testing import DummyRequest, testConfig
import pytest
import transaction
Expand Down Expand Up @@ -121,28 +120,6 @@ def testapp(app, tm, dbsession):

return testapp

@pytest.fixture
def app_request(app, tm, dbsession):
"""
A real request.
This request is almost identical to a real request but it has some
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'

# without this, request.dbsession will be joined to the same transaction
# manager but it will be using a different sqlalchemy.orm.Session using
# a separate database transaction
request.dbsession = dbsession
request.tm = tm

yield request
env['closer']()

@pytest.fixture
def dummy_request(tm, dbsession):
"""
Expand Down
23 changes: 0 additions & 23 deletions docs/tutorials/wiki2/src/views/tests/conftest.py
Expand Up @@ -3,7 +3,6 @@
import alembic.command
import os
from pyramid.paster import get_appsettings
from pyramid.scripting import prepare
from pyramid.testing import DummyRequest, testConfig
import pytest
import transaction
Expand Down Expand Up @@ -80,28 +79,6 @@ def testapp(app, tm, dbsession):

return testapp

@pytest.fixture
def app_request(app, tm, dbsession):
"""
A real request.
This request is almost identical to a real request but it has some
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'

# without this, request.dbsession will be joined to the same transaction
# manager but it will be using a different sqlalchemy.orm.Session using
# a separate database transaction
request.dbsession = dbsession
request.tm = tm

yield request
env['closer']()

@pytest.fixture
def dummy_request(tm, dbsession):
"""
Expand Down
3 changes: 0 additions & 3 deletions docs/tutorials/wiki2/tests.rst
Expand Up @@ -63,9 +63,6 @@ Per-test fixtures
The ``testapp`` is able to mutate the request environ such that the ``dbsession`` and ``tm`` fixtures are injected and used by any code that's touching ``request.dbsession`` and ``request.tm``.
The ``testapp`` maintains a cookiejar, so it can be used to share state across requests, as well as the transaction database connection.

- ``app_request`` - a :class:`pyramid.request.Request` object that can be used for more lightweight tests versus the full ``testapp``.
The ``app_request`` can be passed to view functions and other code that need a fully functional request object.

- ``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.

Expand Down

0 comments on commit 86cb46d

Please sign in to comment.