diff options
| author | Michael Merickel <michael@merickel.org> | 2021-01-15 13:31:48 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-15 13:31:48 -0600 |
| commit | 074f4f3eeec94b133293c0d1d0fa81d681b08e37 (patch) | |
| tree | 2c0b41982a2298592a180887a924b67fa16d65e0 /docs/tutorials/wiki/src | |
| parent | 837358ee6be552fd2f990d1ed8d6ea9e1c98d583 (diff) | |
| parent | b0dd658429367dd5e3cd99973bcc9a6763dcc5e7 (diff) | |
| download | pyramid-074f4f3eeec94b133293c0d1d0fa81d681b08e37.tar.gz pyramid-074f4f3eeec94b133293c0d1d0fa81d681b08e37.tar.bz2 pyramid-074f4f3eeec94b133293c0d1d0fa81d681b08e37.zip | |
Merge pull request #3648 from Pylons/prep-2.0-docs
More 2.0 docs prep
Diffstat (limited to 'docs/tutorials/wiki/src')
23 files changed, 136 insertions, 100 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/setup.py b/docs/tutorials/wiki/src/authorization/setup.py index cdfa18e09..f619a9915 100644 --- a/docs/tutorials/wiki/src/authorization/setup.py +++ b/docs/tutorials/wiki/src/authorization/setup.py @@ -20,7 +20,7 @@ requires = [ 'pyramid_tm', 'pyramid_zodbconn', 'transaction', - 'ZODB3', + 'ZODB', ] tests_require = [ 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/setup.py b/docs/tutorials/wiki/src/basiclayout/setup.py index f85780010..d70df0959 100644 --- a/docs/tutorials/wiki/src/basiclayout/setup.py +++ b/docs/tutorials/wiki/src/basiclayout/setup.py @@ -18,7 +18,7 @@ requires = [ 'pyramid_tm', 'pyramid_zodbconn', 'transaction', - 'ZODB3', + 'ZODB', ] tests_require = [ 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/setup.py b/docs/tutorials/wiki/src/installation/setup.py index f85780010..d70df0959 100644 --- a/docs/tutorials/wiki/src/installation/setup.py +++ b/docs/tutorials/wiki/src/installation/setup.py @@ -18,7 +18,7 @@ requires = [ 'pyramid_tm', 'pyramid_zodbconn', 'transaction', - 'ZODB3', + 'ZODB', ] tests_require = [ 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/setup.py b/docs/tutorials/wiki/src/models/setup.py index f85780010..d70df0959 100644 --- a/docs/tutorials/wiki/src/models/setup.py +++ b/docs/tutorials/wiki/src/models/setup.py @@ -18,7 +18,7 @@ requires = [ 'pyramid_tm', 'pyramid_zodbconn', 'transaction', - 'ZODB3', + 'ZODB', ] tests_require = [ 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/tests/setup.py b/docs/tutorials/wiki/src/tests/setup.py index cdfa18e09..f619a9915 100644 --- a/docs/tutorials/wiki/src/tests/setup.py +++ b/docs/tutorials/wiki/src/tests/setup.py @@ -20,7 +20,7 @@ requires = [ 'pyramid_tm', 'pyramid_zodbconn', 'transaction', - 'ZODB3', + 'ZODB', ] tests_require = [ 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/setup.py b/docs/tutorials/wiki/src/views/setup.py index 86c778bf2..786691e21 100644 --- a/docs/tutorials/wiki/src/views/setup.py +++ b/docs/tutorials/wiki/src/views/setup.py @@ -19,7 +19,7 @@ requires = [ 'pyramid_tm', 'pyramid_zodbconn', 'transaction', - 'ZODB3', + 'ZODB', ] tests_require = [ 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 |
