diff options
| -rw-r--r-- | docs/tutorials/wiki/src/authorization/README.txt | 7 | ||||
| -rw-r--r-- | docs/tutorials/wiki/src/authorization/pytest.ini | 2 | ||||
| -rw-r--r-- | docs/tutorials/wiki/src/authorization/tests/conftest.py | 34 | ||||
| -rw-r--r-- | docs/tutorials/wiki/src/basiclayout/README.txt | 7 | ||||
| -rw-r--r-- | docs/tutorials/wiki/src/basiclayout/pytest.ini | 2 | ||||
| -rw-r--r-- | docs/tutorials/wiki/src/basiclayout/tests/conftest.py | 34 | ||||
| -rw-r--r-- | docs/tutorials/wiki/src/installation/README.txt | 7 | ||||
| -rw-r--r-- | docs/tutorials/wiki/src/installation/pytest.ini | 2 | ||||
| -rw-r--r-- | docs/tutorials/wiki/src/installation/tests/conftest.py | 34 | ||||
| -rw-r--r-- | docs/tutorials/wiki/src/models/README.txt | 7 | ||||
| -rw-r--r-- | docs/tutorials/wiki/src/models/pytest.ini | 2 | ||||
| -rw-r--r-- | docs/tutorials/wiki/src/models/tests/conftest.py | 34 | ||||
| -rw-r--r-- | docs/tutorials/wiki/src/tests/README.txt | 7 | ||||
| -rw-r--r-- | docs/tutorials/wiki/src/tests/pytest.ini | 2 | ||||
| -rw-r--r-- | docs/tutorials/wiki/src/views/README.txt | 7 | ||||
| -rw-r--r-- | docs/tutorials/wiki/src/views/pytest.ini | 2 | ||||
| -rw-r--r-- | docs/tutorials/wiki/src/views/tests/conftest.py | 34 |
17 files changed, 130 insertions, 94 deletions
diff --git a/docs/tutorials/wiki/src/authorization/README.txt b/docs/tutorials/wiki/src/authorization/README.txt index 8a56d14af..b4a924cc4 100644 --- a/docs/tutorials/wiki/src/authorization/README.txt +++ b/docs/tutorials/wiki/src/authorization/README.txt @@ -4,15 +4,16 @@ myproj Getting Started --------------- -- Change directory into your newly created project. +- Change directory into your newly created project if not already there. Your + current directory should be the same as this README.txt file and setup.py. cd tutorial -- Create a Python virtual environment. +- Create a Python virtual environment, if not already created. python3 -m venv env -- Upgrade packaging tools. +- Upgrade packaging tools, if necessary. env/bin/pip install --upgrade pip setuptools diff --git a/docs/tutorials/wiki/src/authorization/pytest.ini b/docs/tutorials/wiki/src/authorization/pytest.ini index 42c3259f9..3df78fe9d 100644 --- a/docs/tutorials/wiki/src/authorization/pytest.ini +++ b/docs/tutorials/wiki/src/authorization/pytest.ini @@ -1,5 +1,5 @@ [pytest] -addopts = --strict +addopts = --strict-markers testpaths = tutorial diff --git a/docs/tutorials/wiki/src/authorization/tests/conftest.py b/docs/tutorials/wiki/src/authorization/tests/conftest.py index 6a702ae12..86793408d 100644 --- a/docs/tutorials/wiki/src/authorization/tests/conftest.py +++ b/docs/tutorials/wiki/src/authorization/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 diff --git a/docs/tutorials/wiki/src/basiclayout/README.txt b/docs/tutorials/wiki/src/basiclayout/README.txt index 8a56d14af..b4a924cc4 100644 --- a/docs/tutorials/wiki/src/basiclayout/README.txt +++ b/docs/tutorials/wiki/src/basiclayout/README.txt @@ -4,15 +4,16 @@ myproj Getting Started --------------- -- Change directory into your newly created project. +- Change directory into your newly created project if not already there. Your + current directory should be the same as this README.txt file and setup.py. cd tutorial -- Create a Python virtual environment. +- Create a Python virtual environment, if not already created. python3 -m venv env -- Upgrade packaging tools. +- Upgrade packaging tools, if necessary. env/bin/pip install --upgrade pip setuptools diff --git a/docs/tutorials/wiki/src/basiclayout/pytest.ini b/docs/tutorials/wiki/src/basiclayout/pytest.ini index 42c3259f9..3df78fe9d 100644 --- a/docs/tutorials/wiki/src/basiclayout/pytest.ini +++ b/docs/tutorials/wiki/src/basiclayout/pytest.ini @@ -1,5 +1,5 @@ [pytest] -addopts = --strict +addopts = --strict-markers testpaths = tutorial diff --git a/docs/tutorials/wiki/src/basiclayout/tests/conftest.py b/docs/tutorials/wiki/src/basiclayout/tests/conftest.py index 6a702ae12..86793408d 100644 --- a/docs/tutorials/wiki/src/basiclayout/tests/conftest.py +++ b/docs/tutorials/wiki/src/basiclayout/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 diff --git a/docs/tutorials/wiki/src/installation/README.txt b/docs/tutorials/wiki/src/installation/README.txt index 8a56d14af..b4a924cc4 100644 --- a/docs/tutorials/wiki/src/installation/README.txt +++ b/docs/tutorials/wiki/src/installation/README.txt @@ -4,15 +4,16 @@ myproj Getting Started --------------- -- Change directory into your newly created project. +- Change directory into your newly created project if not already there. Your + current directory should be the same as this README.txt file and setup.py. cd tutorial -- Create a Python virtual environment. +- Create a Python virtual environment, if not already created. python3 -m venv env -- Upgrade packaging tools. +- Upgrade packaging tools, if necessary. env/bin/pip install --upgrade pip setuptools diff --git a/docs/tutorials/wiki/src/installation/pytest.ini b/docs/tutorials/wiki/src/installation/pytest.ini index 42c3259f9..3df78fe9d 100644 --- a/docs/tutorials/wiki/src/installation/pytest.ini +++ b/docs/tutorials/wiki/src/installation/pytest.ini @@ -1,5 +1,5 @@ [pytest] -addopts = --strict +addopts = --strict-markers testpaths = tutorial diff --git a/docs/tutorials/wiki/src/installation/tests/conftest.py b/docs/tutorials/wiki/src/installation/tests/conftest.py index 6a702ae12..86793408d 100644 --- a/docs/tutorials/wiki/src/installation/tests/conftest.py +++ b/docs/tutorials/wiki/src/installation/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 diff --git a/docs/tutorials/wiki/src/models/README.txt b/docs/tutorials/wiki/src/models/README.txt index 8a56d14af..b4a924cc4 100644 --- a/docs/tutorials/wiki/src/models/README.txt +++ b/docs/tutorials/wiki/src/models/README.txt @@ -4,15 +4,16 @@ myproj Getting Started --------------- -- Change directory into your newly created project. +- Change directory into your newly created project if not already there. Your + current directory should be the same as this README.txt file and setup.py. cd tutorial -- Create a Python virtual environment. +- Create a Python virtual environment, if not already created. python3 -m venv env -- Upgrade packaging tools. +- Upgrade packaging tools, if necessary. env/bin/pip install --upgrade pip setuptools diff --git a/docs/tutorials/wiki/src/models/pytest.ini b/docs/tutorials/wiki/src/models/pytest.ini index 42c3259f9..3df78fe9d 100644 --- a/docs/tutorials/wiki/src/models/pytest.ini +++ b/docs/tutorials/wiki/src/models/pytest.ini @@ -1,5 +1,5 @@ [pytest] -addopts = --strict +addopts = --strict-markers testpaths = tutorial 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 diff --git a/docs/tutorials/wiki/src/tests/README.txt b/docs/tutorials/wiki/src/tests/README.txt index 8a56d14af..b4a924cc4 100644 --- a/docs/tutorials/wiki/src/tests/README.txt +++ b/docs/tutorials/wiki/src/tests/README.txt @@ -4,15 +4,16 @@ myproj Getting Started --------------- -- Change directory into your newly created project. +- Change directory into your newly created project if not already there. Your + current directory should be the same as this README.txt file and setup.py. cd tutorial -- Create a Python virtual environment. +- Create a Python virtual environment, if not already created. python3 -m venv env -- Upgrade packaging tools. +- Upgrade packaging tools, if necessary. env/bin/pip install --upgrade pip setuptools diff --git a/docs/tutorials/wiki/src/tests/pytest.ini b/docs/tutorials/wiki/src/tests/pytest.ini index 42c3259f9..3df78fe9d 100644 --- a/docs/tutorials/wiki/src/tests/pytest.ini +++ b/docs/tutorials/wiki/src/tests/pytest.ini @@ -1,5 +1,5 @@ [pytest] -addopts = --strict +addopts = --strict-markers testpaths = tutorial diff --git a/docs/tutorials/wiki/src/views/README.txt b/docs/tutorials/wiki/src/views/README.txt index 8a56d14af..b4a924cc4 100644 --- a/docs/tutorials/wiki/src/views/README.txt +++ b/docs/tutorials/wiki/src/views/README.txt @@ -4,15 +4,16 @@ myproj Getting Started --------------- -- Change directory into your newly created project. +- Change directory into your newly created project if not already there. Your + current directory should be the same as this README.txt file and setup.py. cd tutorial -- Create a Python virtual environment. +- Create a Python virtual environment, if not already created. python3 -m venv env -- Upgrade packaging tools. +- Upgrade packaging tools, if necessary. env/bin/pip install --upgrade pip setuptools diff --git a/docs/tutorials/wiki/src/views/pytest.ini b/docs/tutorials/wiki/src/views/pytest.ini index 42c3259f9..3df78fe9d 100644 --- a/docs/tutorials/wiki/src/views/pytest.ini +++ b/docs/tutorials/wiki/src/views/pytest.ini @@ -1,5 +1,5 @@ [pytest] -addopts = --strict +addopts = --strict-markers testpaths = tutorial diff --git a/docs/tutorials/wiki/src/views/tests/conftest.py b/docs/tutorials/wiki/src/views/tests/conftest.py index 6a702ae12..86793408d 100644 --- a/docs/tutorials/wiki/src/views/tests/conftest.py +++ b/docs/tutorials/wiki/src/views/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 |
