summaryrefslogtreecommitdiff
path: root/docs/tutorials
diff options
context:
space:
mode:
authorMichael Merickel <michael@merickel.org>2021-01-15 13:31:48 -0600
committerGitHub <noreply@github.com>2021-01-15 13:31:48 -0600
commit074f4f3eeec94b133293c0d1d0fa81d681b08e37 (patch)
tree2c0b41982a2298592a180887a924b67fa16d65e0 /docs/tutorials
parent837358ee6be552fd2f990d1ed8d6ea9e1c98d583 (diff)
parentb0dd658429367dd5e3cd99973bcc9a6763dcc5e7 (diff)
downloadpyramid-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')
-rw-r--r--docs/tutorials/wiki/authorization.rst17
-rw-r--r--docs/tutorials/wiki/installation.rst19
-rw-r--r--docs/tutorials/wiki/src/authorization/README.txt7
-rw-r--r--docs/tutorials/wiki/src/authorization/pytest.ini2
-rw-r--r--docs/tutorials/wiki/src/authorization/setup.py2
-rw-r--r--docs/tutorials/wiki/src/authorization/tests/conftest.py34
-rw-r--r--docs/tutorials/wiki/src/basiclayout/README.txt7
-rw-r--r--docs/tutorials/wiki/src/basiclayout/pytest.ini2
-rw-r--r--docs/tutorials/wiki/src/basiclayout/setup.py2
-rw-r--r--docs/tutorials/wiki/src/basiclayout/tests/conftest.py34
-rw-r--r--docs/tutorials/wiki/src/installation/README.txt7
-rw-r--r--docs/tutorials/wiki/src/installation/pytest.ini2
-rw-r--r--docs/tutorials/wiki/src/installation/setup.py2
-rw-r--r--docs/tutorials/wiki/src/installation/tests/conftest.py34
-rw-r--r--docs/tutorials/wiki/src/models/README.txt7
-rw-r--r--docs/tutorials/wiki/src/models/pytest.ini2
-rw-r--r--docs/tutorials/wiki/src/models/setup.py2
-rw-r--r--docs/tutorials/wiki/src/models/tests/conftest.py34
-rw-r--r--docs/tutorials/wiki/src/tests/README.txt7
-rw-r--r--docs/tutorials/wiki/src/tests/pytest.ini2
-rw-r--r--docs/tutorials/wiki/src/tests/setup.py2
-rw-r--r--docs/tutorials/wiki/src/views/README.txt7
-rw-r--r--docs/tutorials/wiki/src/views/pytest.ini2
-rw-r--r--docs/tutorials/wiki/src/views/setup.py2
-rw-r--r--docs/tutorials/wiki/src/views/tests/conftest.py34
-rw-r--r--docs/tutorials/wiki2/authentication.rst2
-rw-r--r--docs/tutorials/wiki2/installation.rst16
27 files changed, 159 insertions, 131 deletions
diff --git a/docs/tutorials/wiki/authorization.rst b/docs/tutorials/wiki/authorization.rst
index 9c685639d..2b700ee5b 100644
--- a/docs/tutorials/wiki/authorization.rst
+++ b/docs/tutorials/wiki/authorization.rst
@@ -164,7 +164,7 @@ Add an ACL
Open ``tutorial/models/__init__.py`` and add the following import statement near the top:
.. literalinclude:: src/authorization/tutorial/models/__init__.py
- :lines: 4-7
+ :lines: 3-6
:lineno-match:
:language: python
@@ -315,6 +315,14 @@ Launch a browser and visit each of the following URLs, checking that the result
This always redirects to the ``view_page`` view of the ``FrontPage`` Page resource.
It is executable by any user.
+- http://localhost:6543/login invokes the ``login`` view, and a login form will be displayed.
+ On every page, there is a "Login" link in the upper right corner while the user is not authenticated, else it is a "Logout" link when the user is authenticated.
+
+ Supplying the credentials with either the username ``editor`` and password ``editor`` will authenticate the user and grant access for that group.
+
+ After logging in (as a result of hitting an edit or add page and submitting valid credentials), we will see a "Logout" link in the upper right hand corner.
+ When we click it, we are logged out, redirected back to the front page, and a "Login" link is shown in the upper right hand corner.
+
- http://localhost:6543/FrontPage invokes the ``view_page`` view of the ``FrontPage`` Page resource.
This is because it is the :term:`default view` (a view without a ``name``) for ``Page`` resources.
It is executable by any user.
@@ -322,14 +330,11 @@ Launch a browser and visit each of the following URLs, checking that the result
- http://localhost:6543/FrontPage/edit_page invokes the edit view for the FrontPage object.
It is executable by only the ``editor`` user.
If a different user (or the anonymous user) invokes it, then a login form will be displayed.
- Supplying the credentials with the username ``editor`` and password ``editor`` will display the edit page form.
+ The ``editor`` user will see the edit page form.
- http://localhost:6543/add_page/SomePageName invokes the add view for a page.
It is executable by only the ``editor`` user.
If a different user (or the anonymous user) invokes it, a login form will be displayed.
- Supplying the credentials with the username ``editor``, password ``editor`` will display the edit page form.
-
-- After logging in (as a result of hitting an edit or add page and submitting the login form with the ``editor`` credentials), we will see a Logout link in the upper right hand corner.
- When we click it, we are logged out, and redirected back to the front page.
+ The ``editor`` user will see the edit page form.
- To generate a not found error, visit http://localhost:6543/wakawaka which will invoke the ``notfound_view`` view provided by the cookiecutter.
diff --git a/docs/tutorials/wiki/installation.rst b/docs/tutorials/wiki/installation.rst
index 4de9b4b9c..7113c4bc2 100644
--- a/docs/tutorials/wiki/installation.rst
+++ b/docs/tutorials/wiki/installation.rst
@@ -185,20 +185,7 @@ The console will show ``pip`` checking for packages and installing missing packa
.. code-block:: bash
- Successfully installed BTrees-4.6.1 Chameleon-3.6.2 Mako-1.1.0 \
- MarkupSafe-1.1.1 PasteDeploy-2.0.1 Pygments-2.5.2 WebTest-2.0.33 \
- ZConfig-3.5.0 ZEO-5.2.1 ZODB-5.5.1 ZODB3-3.11.0 attrs-19.3.0 \
- beautifulsoup4-4.8.2 cffi-1.13.2 coverage-5.0.3 hupper-1.9.1 \
- importlib-metadata-1.4.0 more-itertools-8.1.0 packaging-20.0 \
- persistent-4.5.1 plaster-1.0 plaster-pastedeploy-0.7 pluggy-0.13.1 \
- py-1.8.1 pycparser-2.19 pyparsing-2.4.6 pyramid-1.10.4 \
- pyramid-chameleon-0.3 pyramid-debugtoolbar-4.5.2 pyramid-mako-1.1.0 \
- pyramid-retry-2.1 pyramid-tm-2.4 pyramid-zodbconn-0.8.1 pytest-5.3.2 \
- pytest-cov-2.8.1 repoze.lru-0.7 six-1.13.0 soupsieve-1.9.5 \
- transaction-3.0.0 translationstring-1.3 tutorial venusian-3.0.0 \
- waitress-1.4.2 wcwidth-0.1.8 webob-1.8.5 zc.lockfile-2.0 zdaemon-4.3 \
- zipp-0.6.0 zodbpickle-2.0.0 zodburi-2.4.0 zope.deprecation-4.4.0 \
- zope.interface-4.7.1
+ Successfully installed BTrees-4.7.2 Chameleon-3.8.1 Mako-1.1.3 MarkupSafe-1.1.1 PasteDeploy-2.1.1 Pygments-2.7.3 WebTest-2.0.35 ZConfig-3.5.0 ZEO-5.2.2 ZODB-5.6.0 attrs-20.3.0 beautifulsoup4-4.9.3 cffi-1.14.4 coverage-5.3.1 hupper-1.10.2 iniconfig-1.1.1 packaging-20.8 persistent-4.6.4 plaster-1.0 plaster-pastedeploy-0.7 pluggy-0.13.1 py-1.10.0 pycparser-2.20 pyparsing-2.4.7 pyramid-1.10.5 pyramid-chameleon-0.3 pyramid-debugtoolbar-4.9 pyramid-mako-1.1.0 pyramid-retry-2.1.1 pyramid-tm-2.4 pyramid-zodbconn-0.8.1 pytest-6.2.1 pytest-cov-2.10.1 repoze.lru-0.7 six-1.15.0 soupsieve-2.1 toml-0.10.2 transaction-3.0.1 translationstring-1.4 tutorial venusian-3.0.0 waitress-1.4.4 webob-1.8.6 zc.lockfile-2.0 zdaemon-4.3 zodbpickle-2.0.0 zodburi-2.4.0 zope.deprecation-4.4.0 zope.interface-5.2.0
Testing requirements are defined in our project's ``setup.py`` file, in the ``tests_require`` and ``extras_require`` stanzas.
@@ -276,9 +263,9 @@ If successful, you will see output something like this:
.. code-block:: bash
======================== test session starts =========================
- platform darwin -- Python 3.7.3, pytest-5.3.2, py-1.8.1, pluggy-0.13.1
+ platform darwin -- Python 3.9.0, pytest-6.2.1, py-1.10.0, pluggy-0.13.1
rootdir: /filepath/tutorial, inifile: pytest.ini, testpaths: tutorial
- plugins: cov-2.8.1
+ plugins: cov-2.10.1
collected 4 items
tests/test_functional.py .. [ 50%]
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
diff --git a/docs/tutorials/wiki2/authentication.rst b/docs/tutorials/wiki2/authentication.rst
index a798e7748..e8a770491 100644
--- a/docs/tutorials/wiki2/authentication.rst
+++ b/docs/tutorials/wiki2/authentication.rst
@@ -40,7 +40,7 @@ Update ``tutorial/security.py`` with the following content:
:linenos:
:language: python
-Here we've defined a new security policy named ``MySecurityPolicy``, which is implementing most of the :class:`pyramid.interfaces.ISecurityPolicy` interface by tracking a :term:`identity` using a signed cookie implemented by :class:`pyramid.authentication.AuthTktCookieHelper` (lines 8-34).
+Here we've defined a new security policy named ``MySecurityPolicy``, which is implementing most of the :class:`pyramid.interfaces.ISecurityPolicy` interface by tracking an :term:`identity` using a signed cookie implemented by :class:`pyramid.authentication.AuthTktCookieHelper` (lines 8-34).
The security policy outputs the authenticated ``tutorial.models.User`` object for the logged-in user as the :term:`identity`, which is available as ``request.identity``.
Our new :term:`security policy` defines how our application will remember, forget, and identify users.
diff --git a/docs/tutorials/wiki2/installation.rst b/docs/tutorials/wiki2/installation.rst
index 004f6ed31..c961d490b 100644
--- a/docs/tutorials/wiki2/installation.rst
+++ b/docs/tutorials/wiki2/installation.rst
@@ -338,15 +338,15 @@ If successful, you will see output something like this:
.. code-block:: bash
======================== test session starts ========================
- platform -- Python 3.7.3, pytest-5.3.2, py-1.8.1, pluggy-0.13.1
+ platform darwin -- Python 3.9.0, pytest-6.2.1, py-1.10.0, pluggy-0.13.1
rootdir: <somepath>/tutorial, inifile: pytest.ini, testpaths: tutorial, tests
- plugins: cov-2.8.1
+ plugins: cov-2.10.1
collected 5 items
- tests/test_functional.py ..
- tests/test_views.py ...
+ tests/test_functional.py .. [ 40%]
+ tests/test_views.py ... [100%]
- ---------- coverage: platform darwin, python 3.7.4-final-0 -----------
+ ---------- coverage: platform darwin, python 3.9.0-final-0 -----------
Name Stmts Miss Cover Missing
----------------------------------------------------------------------------------
tutorial/__init__.py 8 0 100%
@@ -360,10 +360,10 @@ If successful, you will see output something like this:
tutorial/scripts/__init__.py 0 0 100%
tutorial/scripts/initialize_db.py 22 14 36% 15-16, 20-25, 29-38
tutorial/views/__init__.py 0 0 100%
- tutorial/views/default.py 12 0 100%
- tutorial/views/notfound.py 4 0 100%
+ tutorial/views/default.py 13 0 100%
+ tutorial/views/notfound.py 5 0 100%
----------------------------------------------------------------------------------
- TOTAL 136 27 80%
+ TOTAL 138 27 80%
===================== 5 passed in 0.77 seconds ======================