From 84672a3c592a3d0cdcdec549dcd72c226d938694 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sat, 9 Jan 2021 07:25:43 -0800 Subject: Update files from cookiecutter and output from commands --- docs/narr/myproject/.gitignore | 2 +- docs/narr/myproject/README.txt | 7 ++++--- docs/narr/myproject/pytest.ini | 2 +- docs/narr/myproject/tests/conftest.py | 33 ++++++++++++++++++++------------- docs/narr/project.rst | 8 ++------ 5 files changed, 28 insertions(+), 24 deletions(-) (limited to 'docs') diff --git a/docs/narr/myproject/.gitignore b/docs/narr/myproject/.gitignore index c612e59f2..e9336274d 100644 --- a/docs/narr/myproject/.gitignore +++ b/docs/narr/myproject/.gitignore @@ -11,7 +11,7 @@ dist/ nosetests.xml env*/ tmp/ -Data.fs* +Data*.fs* *.sublime-project *.sublime-workspace .*.sw? diff --git a/docs/narr/myproject/README.txt b/docs/narr/myproject/README.txt index 6c5a0fee0..0a71384dc 100644 --- a/docs/narr/myproject/README.txt +++ b/docs/narr/myproject/README.txt @@ -4,15 +4,16 @@ myproject 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 myproject -- 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/narr/myproject/pytest.ini b/docs/narr/myproject/pytest.ini index 5c8c59068..074237039 100644 --- a/docs/narr/myproject/pytest.ini +++ b/docs/narr/myproject/pytest.ini @@ -1,5 +1,5 @@ [pytest] -addopts = --strict +addopts = --strict-markers testpaths = myproject diff --git a/docs/narr/myproject/tests/conftest.py b/docs/narr/myproject/tests/conftest.py index 296205927..ec09cdb2d 100644 --- a/docs/narr/myproject/tests/conftest.py +++ b/docs/narr/myproject/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 webtest @@ -41,29 +41,36 @@ def app_request(app): 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' - - 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): +def dummy_request(): """ 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' 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/narr/project.rst b/docs/narr/project.rst index ee75587e9..bd4c675d9 100644 --- a/docs/narr/project.rst +++ b/docs/narr/project.rst @@ -208,12 +208,7 @@ Elided output from a run of this command on Unix is shown below: .. code-block:: bash Running setup.py develop for myproject - Successfully installed Jinja2-2.10.3 Mako-1.1.0 MarkupSafe-1.1.1 \ - PasteDeploy-2.0.1 Pygments-2.5.2 hupper-1.9.1 myproject plaster-1.0 \ - plaster-pastedeploy-0.7 pyramid-1.10.4 pyramid-debugtoolbar-4.5.2 \ - pyramid-jinja2-2.8 pyramid-mako-1.1.0 repoze.lru-0.7 \ - translationstring-1.3 venusian-3.0.0 waitress-1.4.2 webob-1.8.5 \ - zope.deprecation-4.4.0 zope.interface-4.7.1 + Successfully installed Jinja2-2.11.2 Mako-1.1.3 MarkupSafe-1.1.1 PasteDeploy-2.1.1 Pygments-2.7.3 hupper-1.10.2 myproject plaster-1.0 plaster-pastedeploy-0.7 pyramid-1.10.5 pyramid-debugtoolbar-4.9 pyramid-jinja2-2.8 pyramid-mako-1.1.0 repoze.lru-0.7 translationstring-1.4 venusian-3.0.0 waitress-1.4.4 webob-1.8.6 zope.deprecation-4.4.0 zope.interface-5.2.0 This will install a :term:`distribution` representing your project into the virtual environment interpreter's library set so it can be found by ``import`` @@ -555,6 +550,7 @@ The ``myproject`` project we've generated has the following directory structure: │   └── notfound.py ├── production.ini ├── pytest.ini + ├── setup.py ├── testing.ini └── tests ├── __init__.py -- cgit v1.2.3