summaryrefslogtreecommitdiff
path: root/docs/tutorials
diff options
context:
space:
mode:
authorSteve Piercy <web@stevepiercy.com>2021-01-09 04:56:15 -0800
committerSteve Piercy <web@stevepiercy.com>2021-01-09 04:56:15 -0800
commit0235bd17c7a02cbdb833f57f1af7a0deeec9b8b4 (patch)
tree59c32a6c3cbb9e3c92e629a39f06f7abc3e3648e /docs/tutorials
parent16d66c801d20010036d2d89e2f20e4156e19aa3e (diff)
downloadpyramid-0235bd17c7a02cbdb833f57f1af7a0deeec9b8b4.tar.gz
pyramid-0235bd17c7a02cbdb833f57f1af7a0deeec9b8b4.tar.bz2
pyramid-0235bd17c7a02cbdb833f57f1af7a0deeec9b8b4.zip
Update conftest.py, pytest.ini, and README.txt for all steps where needed
Diffstat (limited to 'docs/tutorials')
-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/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/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/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/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/views/README.txt7
-rw-r--r--docs/tutorials/wiki/src/views/pytest.ini2
-rw-r--r--docs/tutorials/wiki/src/views/tests/conftest.py34
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