summaryrefslogtreecommitdiff
path: root/docs/quick_tutorial
diff options
context:
space:
mode:
Diffstat (limited to 'docs/quick_tutorial')
-rw-r--r--docs/quick_tutorial/authentication.rst2
-rw-r--r--docs/quick_tutorial/authentication/setup.py28
-rw-r--r--docs/quick_tutorial/authorization/setup.py28
-rw-r--r--docs/quick_tutorial/cookiecutters.rst9
-rw-r--r--docs/quick_tutorial/databases.rst128
-rw-r--r--docs/quick_tutorial/databases/setup.py33
-rw-r--r--docs/quick_tutorial/debugtoolbar.rst76
-rw-r--r--docs/quick_tutorial/debugtoolbar/setup.py28
-rw-r--r--docs/quick_tutorial/forms.rst85
-rw-r--r--docs/quick_tutorial/forms/setup.py28
-rw-r--r--docs/quick_tutorial/forms/tutorial/tests.py30
-rw-r--r--docs/quick_tutorial/functional_testing.rst43
-rw-r--r--docs/quick_tutorial/functional_testing/setup.py30
-rw-r--r--docs/quick_tutorial/ini.rst69
-rw-r--r--docs/quick_tutorial/ini/setup.py18
-rw-r--r--docs/quick_tutorial/jinja2.rst58
-rw-r--r--docs/quick_tutorial/jinja2/setup.py32
-rw-r--r--docs/quick_tutorial/json.rst2
-rw-r--r--docs/quick_tutorial/json/setup.py28
-rw-r--r--docs/quick_tutorial/logging.rst2
-rw-r--r--docs/quick_tutorial/logging/setup.py28
-rw-r--r--docs/quick_tutorial/more_view_classes.rst4
-rw-r--r--docs/quick_tutorial/more_view_classes/setup.py28
-rw-r--r--docs/quick_tutorial/package/setup.py7
-rw-r--r--docs/quick_tutorial/request_response.rst2
-rw-r--r--docs/quick_tutorial/request_response/setup.py31
-rw-r--r--docs/quick_tutorial/retail_forms/setup.py16
-rw-r--r--docs/quick_tutorial/routing.rst2
-rw-r--r--docs/quick_tutorial/routing/setup.py28
-rw-r--r--docs/quick_tutorial/sessions.rst2
-rw-r--r--docs/quick_tutorial/sessions/setup.py28
-rw-r--r--docs/quick_tutorial/static_assets.rst2
-rw-r--r--docs/quick_tutorial/static_assets/setup.py28
-rw-r--r--docs/quick_tutorial/templating.rst71
-rw-r--r--docs/quick_tutorial/templating/setup.py28
-rw-r--r--docs/quick_tutorial/tutorial_approach.rst6
-rw-r--r--docs/quick_tutorial/unit_testing.rst43
-rw-r--r--docs/quick_tutorial/unit_testing/setup.py29
-rw-r--r--docs/quick_tutorial/view_classes.rst41
-rw-r--r--docs/quick_tutorial/view_classes/setup.py28
-rw-r--r--docs/quick_tutorial/views.rst2
-rw-r--r--docs/quick_tutorial/views/setup.py30
42 files changed, 799 insertions, 442 deletions
diff --git a/docs/quick_tutorial/authentication.rst b/docs/quick_tutorial/authentication.rst
index eb9b6b395..cd038ea36 100644
--- a/docs/quick_tutorial/authentication.rst
+++ b/docs/quick_tutorial/authentication.rst
@@ -39,7 +39,7 @@ Steps
.. literalinclude:: authentication/setup.py
:language: python
- :emphasize-lines: 4
+ :emphasize-lines: 6
:linenos:
#. We can now install our project in development mode:
diff --git a/docs/quick_tutorial/authentication/setup.py b/docs/quick_tutorial/authentication/setup.py
index a5117af5a..64366a2df 100644
--- a/docs/quick_tutorial/authentication/setup.py
+++ b/docs/quick_tutorial/authentication/setup.py
@@ -1,5 +1,7 @@
from setuptools import setup
+# List of dependencies installed via `pip install -e .`
+# by virtue of the Setuptools `install_requires` value below.
requires = [
'bcrypt',
'pyramid',
@@ -7,10 +9,24 @@ requires = [
'waitress',
]
-setup(name='tutorial',
- install_requires=requires,
- entry_points="""\
- [paste.app_factory]
- main = tutorial:main
- """,
+# List of dependencies installed via `pip install -e ".[dev]"`
+# by virtue of the Setuptools `extras_require` value in the Python
+# dictionary below.
+dev_requires = [
+ 'pyramid_debugtoolbar',
+ 'pytest',
+ 'webtest',
+]
+
+setup(
+ name='tutorial',
+ install_requires=requires,
+ extras_require={
+ 'dev': dev_requires,
+ },
+ entry_points={
+ 'paste.app_factory': [
+ 'main = tutorial:main'
+ ],
+ },
)
diff --git a/docs/quick_tutorial/authorization/setup.py b/docs/quick_tutorial/authorization/setup.py
index a5117af5a..64366a2df 100644
--- a/docs/quick_tutorial/authorization/setup.py
+++ b/docs/quick_tutorial/authorization/setup.py
@@ -1,5 +1,7 @@
from setuptools import setup
+# List of dependencies installed via `pip install -e .`
+# by virtue of the Setuptools `install_requires` value below.
requires = [
'bcrypt',
'pyramid',
@@ -7,10 +9,24 @@ requires = [
'waitress',
]
-setup(name='tutorial',
- install_requires=requires,
- entry_points="""\
- [paste.app_factory]
- main = tutorial:main
- """,
+# List of dependencies installed via `pip install -e ".[dev]"`
+# by virtue of the Setuptools `extras_require` value in the Python
+# dictionary below.
+dev_requires = [
+ 'pyramid_debugtoolbar',
+ 'pytest',
+ 'webtest',
+]
+
+setup(
+ name='tutorial',
+ install_requires=requires,
+ extras_require={
+ 'dev': dev_requires,
+ },
+ entry_points={
+ 'paste.app_factory': [
+ 'main = tutorial:main'
+ ],
+ },
)
diff --git a/docs/quick_tutorial/cookiecutters.rst b/docs/quick_tutorial/cookiecutters.rst
index 045808884..e4a585a33 100644
--- a/docs/quick_tutorial/cookiecutters.rst
+++ b/docs/quick_tutorial/cookiecutters.rst
@@ -4,7 +4,7 @@
Prelude: Quick Project Startup with Cookiecutters
=================================================
-To ease the process of getting started on a project, the Pylons Project provides :term:`cookiecutter`\ s that generate sample :app:`Pyramid` projects from project templates. These cookiecutters will install :app:`Pyramid` and its dependencies as well. We will still cover many topics of web application development using :app:`Pyramid`, but it's good to know of this facility. This prelude will demonstrate how to get a working :app:`Pyramid` web application running via ``cookiecutter``.
+To ease the process of getting started on a project, the Pylons Project provides a :term:`cookiecutter` that generates sample :app:`Pyramid` projects from project templates. The cookiecutter will install :app:`Pyramid` and its dependencies as well. We will still cover many topics of web application development using :app:`Pyramid`, but it's good to know of this facility. This prelude will demonstrate how to get a working :app:`Pyramid` web application running via ``cookiecutter``.
Objectives
@@ -43,6 +43,11 @@ Steps
2 - chameleon
3 - mako
Choose from 1, 2, 3 [1]: 1
+ Select backend:
+ 1 - none
+ 2 - sqlalchemy
+ 3 - zodb
+ Choose from 1, 2, 3 [1]: 1
#. We then run through the following commands.
@@ -79,7 +84,7 @@ Analysis
========
Rather than starting from scratch, a cookiecutter can make it easy to get a Python
-project containing a working :app:`Pyramid` application. The Pylons Project provides `several cookiecutters <https://github.com/Pylons?q=pyramid-cookiecutter>`_.
+project containing a working :app:`Pyramid` application.
``pserve`` is :app:`Pyramid`'s application runner, separating operational details from
your code. When you install :app:`Pyramid`, a small command program called ``pserve``
diff --git a/docs/quick_tutorial/databases.rst b/docs/quick_tutorial/databases.rst
index 7d10f2470..db75d70ce 100644
--- a/docs/quick_tutorial/databases.rst
+++ b/docs/quick_tutorial/databases.rst
@@ -21,10 +21,10 @@ storage and retrieval for the wiki pages in the previous step.
.. note::
- The ``pyramid-cookiecutter-alchemy`` cookiecutter is really helpful for getting an SQLAlchemy
- project going, including generation of the console script. Since we want to
- see all the decisions, we will forgo convenience in this tutorial, and wire
- it up ourselves.
+ The Pyramid cookiecutter ``pyramid-cookiecutter-starter`` is really
+ helpful for getting a SQLAlchemy project going, including generation of
+ the console script. Since we want to see all the decisions, we will forgo
+ convenience in this tutorial, and wire it up ourselves.
Objectives
@@ -41,108 +41,100 @@ Objectives
Steps
=====
-#. We are going to use the forms step as our starting point:
+#. We are going to use the forms step as our starting point:
- .. code-block:: bash
+ .. code-block:: bash
- cd ..; cp -r forms databases; cd databases
+ cd ..; cp -r forms databases; cd databases
-#. We need to add some dependencies in ``databases/setup.py`` as well as an
- "entry point" for the command-line script:
+#. We need to add some dependencies in ``databases/setup.py`` as well as an :term:`entry point` for the command-line script:
- .. literalinclude:: databases/setup.py
- :linenos:
+ .. literalinclude:: databases/setup.py
+ :linenos:
+ :emphasize-lines: 9-10, 12, 34-36
- .. note::
+ .. note:: We aren't yet doing ``$VENV/bin/pip install -e .`` because we need to write a script and update configuration first.
- We aren't yet doing ``$VENV/bin/pip install -e .`` as we will change it
- later.
+#. Our configuration file at ``databases/development.ini`` wires together some new pieces:
-#. Our configuration file at ``databases/development.ini`` wires together some
- new pieces:
+ .. literalinclude:: databases/development.ini
+ :language: ini
- .. literalinclude:: databases/development.ini
- :language: ini
+#. This engine configuration now needs to be read into the application through changes in ``databases/tutorial/__init__.py``:
-#. This engine configuration now needs to be read into the application through
- changes in ``databases/tutorial/__init__.py``:
+ .. literalinclude:: databases/tutorial/__init__.py
+ :linenos:
- .. literalinclude:: databases/tutorial/__init__.py
- :linenos:
+#. Make a command-line script at ``databases/tutorial/initialize_db.py`` to initialize the database:
-#. Make a command-line script at ``databases/tutorial/initialize_db.py`` to
- initialize the database:
+ .. literalinclude:: databases/tutorial/initialize_db.py
+ :linenos:
- .. literalinclude:: databases/tutorial/initialize_db.py
- :linenos:
+#. Now that we've got all the pieces ready, and because we changed ``setup.py``, we now install all the goodies:
-#. Since ``setup.py`` changed, we now run it:
+ .. code-block:: bash
- .. code-block:: bash
+ $VENV/bin/pip install -e .
- $VENV/bin/pip install -e .
+#. The script references some models in ``databases/tutorial/models.py``:
-#. The script references some models in ``databases/tutorial/models.py``:
+ .. literalinclude:: databases/tutorial/models.py
+ :linenos:
- .. literalinclude:: databases/tutorial/models.py
- :linenos:
+#. Let's run this console script, thus producing our database and table:
-#. Let's run this console script, thus producing our database and table:
+ .. code-block:: bash
- .. code-block:: bash
+ $VENV/bin/initialize_tutorial_db development.ini
- $VENV/bin/initialize_tutorial_db development.ini
-
- 2016-04-16 13:01:33,055 INFO [sqlalchemy.engine.base.Engine][MainThread] SELECT CAST('test plain returns' AS VARCHAR(60)) AS anon_1
- 2016-04-16 13:01:33,055 INFO [sqlalchemy.engine.base.Engine][MainThread] ()
- 2016-04-16 13:01:33,056 INFO [sqlalchemy.engine.base.Engine][MainThread] SELECT CAST('test unicode returns' AS VARCHAR(60)) AS anon_1
- 2016-04-16 13:01:33,056 INFO [sqlalchemy.engine.base.Engine][MainThread] ()
- 2016-04-16 13:01:33,057 INFO [sqlalchemy.engine.base.Engine][MainThread] PRAGMA table_info("wikipages")
- 2016-04-16 13:01:33,057 INFO [sqlalchemy.engine.base.Engine][MainThread] ()
- 2016-04-16 13:01:33,058 INFO [sqlalchemy.engine.base.Engine][MainThread]
- CREATE TABLE wikipages (
+ 2016-04-16 13:01:33,055 INFO [sqlalchemy.engine.base.Engine][MainThread] SELECT CAST('test plain returns' AS VARCHAR(60)) AS anon_1
+ 2016-04-16 13:01:33,055 INFO [sqlalchemy.engine.base.Engine][MainThread] ()
+ 2016-04-16 13:01:33,056 INFO [sqlalchemy.engine.base.Engine][MainThread] SELECT CAST('test unicode returns' AS VARCHAR(60)) AS anon_1
+ 2016-04-16 13:01:33,056 INFO [sqlalchemy.engine.base.Engine][MainThread] ()
+ 2016-04-16 13:01:33,057 INFO [sqlalchemy.engine.base.Engine][MainThread] PRAGMA table_info("wikipages")
+ 2016-04-16 13:01:33,057 INFO [sqlalchemy.engine.base.Engine][MainThread] ()
+ 2016-04-16 13:01:33,058 INFO [sqlalchemy.engine.base.Engine][MainThread]
+ CREATE TABLE wikipages (
uid INTEGER NOT NULL,
title TEXT,
body TEXT,
PRIMARY KEY (uid),
UNIQUE (title)
- )
+ )
- 2016-04-16 13:01:33,058 INFO [sqlalchemy.engine.base.Engine][MainThread] ()
- 2016-04-16 13:01:33,059 INFO [sqlalchemy.engine.base.Engine][MainThread] COMMIT
- 2016-04-16 13:01:33,062 INFO [sqlalchemy.engine.base.Engine][MainThread] BEGIN (implicit)
- 2016-04-16 13:01:33,062 INFO [sqlalchemy.engine.base.Engine][MainThread] INSERT INTO wikipages (title, body) VALUES (?, ?)
- 2016-04-16 13:01:33,063 INFO [sqlalchemy.engine.base.Engine][MainThread] ('Root', '<p>Root</p>')
- 2016-04-16 13:01:33,063 INFO [sqlalchemy.engine.base.Engine][MainThread] COMMIT
+ 2016-04-16 13:01:33,058 INFO [sqlalchemy.engine.base.Engine][MainThread] ()
+ 2016-04-16 13:01:33,059 INFO [sqlalchemy.engine.base.Engine][MainThread] COMMIT
+ 2016-04-16 13:01:33,062 INFO [sqlalchemy.engine.base.Engine][MainThread] BEGIN (implicit)
+ 2016-04-16 13:01:33,062 INFO [sqlalchemy.engine.base.Engine][MainThread] INSERT INTO wikipages (title, body) VALUES (?, ?)
+ 2016-04-16 13:01:33,063 INFO [sqlalchemy.engine.base.Engine][MainThread] ('Root', '<p>Root</p>')
+ 2016-04-16 13:01:33,063 INFO [sqlalchemy.engine.base.Engine][MainThread] COMMIT
-#. With our data now driven by SQLAlchemy queries, we need to update our
- ``databases/tutorial/views.py``:
+#. With our data now driven by SQLAlchemy queries, we need to update our ``databases/tutorial/views.py``:
- .. literalinclude:: databases/tutorial/views.py
- :linenos:
+ .. literalinclude:: databases/tutorial/views.py
+ :linenos:
-#. Our tests in ``databases/tutorial/tests.py`` changed to include SQLAlchemy
- bootstrapping:
+#. Our tests in ``databases/tutorial/tests.py`` changed to include SQLAlchemy bootstrapping:
- .. literalinclude:: databases/tutorial/tests.py
- :linenos:
+ .. literalinclude:: databases/tutorial/tests.py
+ :linenos:
-#. Run the tests in your package using ``py.test``:
+#. Run the tests in your package using ``pytest``:
- .. code-block:: bash
+ .. code-block:: bash
- $VENV/bin/py.test tutorial/tests.py -q
- ..
- 2 passed in 1.41 seconds
+ $VENV/bin/pytest tutorial/tests.py -q
+ ..
+ 2 passed in 1.41 seconds
-#. Run your Pyramid application with:
+#. Run your Pyramid application with:
- .. code-block:: bash
+ .. code-block:: bash
- $VENV/bin/pserve development.ini --reload
+ $VENV/bin/pserve development.ini --reload
-#. Open http://localhost:6543/ in a browser.
+#. Open http://localhost:6543/ in a browser.
Analysis
diff --git a/docs/quick_tutorial/databases/setup.py b/docs/quick_tutorial/databases/setup.py
index 13d1d6637..c4e4ae2f2 100644
--- a/docs/quick_tutorial/databases/setup.py
+++ b/docs/quick_tutorial/databases/setup.py
@@ -1,5 +1,7 @@
from setuptools import setup
+# List of dependencies installed via `pip install -e .`
+# by virtue of the Setuptools `install_requires` value below.
requires = [
'deform',
'pyramid',
@@ -10,12 +12,27 @@ requires = [
'zope.sqlalchemy',
]
-setup(name='tutorial',
- install_requires=requires,
- entry_points="""\
- [paste.app_factory]
- main = tutorial:main
- [console_scripts]
- initialize_tutorial_db = tutorial.initialize_db:main
- """,
+# List of dependencies installed via `pip install -e ".[dev]"`
+# by virtue of the Setuptools `extras_require` value in the Python
+# dictionary below.
+dev_requires = [
+ 'pyramid_debugtoolbar',
+ 'pytest',
+ 'webtest',
+]
+
+setup(
+ name='tutorial',
+ install_requires=requires,
+ extras_require={
+ 'dev': dev_requires,
+ },
+ entry_points={
+ 'paste.app_factory': [
+ 'main = tutorial:main'
+ ],
+ 'console_scripts': [
+ 'initialize_tutorial_db = tutorial.initialize_db:main'
+ ],
+ },
)
diff --git a/docs/quick_tutorial/debugtoolbar.rst b/docs/quick_tutorial/debugtoolbar.rst
index b49dd1f97..2607c83f2 100644
--- a/docs/quick_tutorial/debugtoolbar.rst
+++ b/docs/quick_tutorial/debugtoolbar.rst
@@ -32,30 +32,40 @@ Objectives
Steps
=====
-#. First we copy the results of the previous step, as well as install the
- ``pyramid_debugtoolbar`` package:
+#. First we copy the results of the previous step.
- .. code-block:: bash
+ .. code-block:: bash
- cd ..; cp -r ini debugtoolbar; cd debugtoolbar
- $VENV/bin/pip install -e .
- $VENV/bin/pip install pyramid_debugtoolbar
+ cd ..; cp -r ini debugtoolbar; cd debugtoolbar
-#. Our ``debugtoolbar/development.ini`` gets a configuration entry for
- ``pyramid.includes``:
+#. Add ``pyramid_debugtoolbar`` to our project's dependencies in ``setup.py`` as a :term:`Setuptools` "extra" for development:
- .. literalinclude:: debugtoolbar/development.ini
- :language: ini
- :linenos:
+ .. literalinclude:: debugtoolbar/setup.py
+ :language: python
+ :linenos:
+ :emphasize-lines: 10-16, 20-22
-#. Run the WSGI application with:
+#. Install our project and its newly added dependency.
+ Note that we use the extra specifier ``[dev]`` to install development requirements and surround it and the period with double quote marks.
- .. code-block:: bash
+ .. code-block:: bash
- $VENV/bin/pserve development.ini --reload
+ $VENV/bin/pip install -e ".[dev]"
-#. Open http://localhost:6543/ in your browser. See the handy
- toolbar on the right.
+#. Our ``debugtoolbar/development.ini`` gets a configuration entry for ``pyramid.includes``:
+
+ .. literalinclude:: debugtoolbar/development.ini
+ :language: ini
+ :linenos:
+
+#. Run the WSGI application with:
+
+ .. code-block:: bash
+
+ $VENV/bin/pserve development.ini --reload
+
+#. Open http://localhost:6543/ in your browser.
+ See the handy toolbar on the right.
Analysis
@@ -87,30 +97,36 @@ experience otherwise inexplicable client-side weirdness, you can shut it off
by commenting out the ``pyramid_debugtoolbar`` line in ``pyramid.includes``
temporarily.
+Finally we've introduced the concept of :term:`Setuptools` extras.
+These are optional or recommended features that may be installed with an "extras" specifier, in this case, ``dev``.
+The specifier is the name of a key in a Python dictionary, and is surrounded by square brackets when invoked on the command line, for example, .
+The value for the key is a Python list of dependencies.
+
.. seealso:: See also :ref:`pyramid_debugtoolbar <toolbar:overview>`.
Extra credit
============
-#. Why don't we add ``pyramid_debugtoolbar`` to the list of
- ``install_requires`` dependencies in ``debugtoolbar/setup.py``?
+#. We added ``pyramid_debugtoolbar`` to the list of ``dev_requires`` dependencies in ``debugtoolbar/setup.py``.
+ We then installed the dependencies via ``pip install -e ".[dev]"`` by virtue of the Setuptools ``extras_require`` value in the Python dictionary.
+ Why did we add them there instead of in the ``requires`` list?
-#. Introduce a bug into your application. Change:
+#. Introduce a bug into your application. Change:
- .. code-block:: python
+ .. code-block:: python
- def hello_world(request):
- return Response('<body><h1>Hello World!</h1></body>')
+ def hello_world(request):
+ return Response('<body><h1>Hello World!</h1></body>')
- to:
+ to:
- .. code-block:: python
+ .. code-block:: python
- def hello_world(request):
- return xResponse('<body><h1>Hello World!</h1></body>')
+ def hello_world(request):
+ return xResponse('<body><h1>Hello World!</h1></body>')
- Save, and visit http://localhost:6543/ again. Notice the nice traceback
- display. On the lowest line, click the "screen" icon to the right, and try
- typing the variable names ``request`` and ``Response``. What else can you
- discover?
+ Save, and visit http://localhost:6543/ again.
+ Notice the nice traceback display.
+ On the lowest line, click the "screen" icon to the right, and try typing the variable names ``request`` and ``Response``.
+ What else can you discover?
diff --git a/docs/quick_tutorial/debugtoolbar/setup.py b/docs/quick_tutorial/debugtoolbar/setup.py
index a93cf6a73..53bc0f5c7 100644
--- a/docs/quick_tutorial/debugtoolbar/setup.py
+++ b/docs/quick_tutorial/debugtoolbar/setup.py
@@ -1,14 +1,28 @@
from setuptools import setup
+# List of dependencies installed via `pip install -e .`
+# by virtue of the Setuptools `install_requires` value below.
requires = [
'pyramid',
'waitress',
]
-setup(name='tutorial',
- install_requires=requires,
- entry_points="""\
- [paste.app_factory]
- main = tutorial:main
- """,
-) \ No newline at end of file
+# List of dependencies installed via `pip install -e ".[dev]"`
+# by virtue of the Setuptools `extras_require` value in the Python
+# dictionary below.
+dev_requires = [
+ 'pyramid_debugtoolbar',
+]
+
+setup(
+ name='tutorial',
+ install_requires=requires,
+ extras_require={
+ 'dev': dev_requires,
+ },
+ entry_points={
+ 'paste.app_factory': [
+ 'main = tutorial:main'
+ ],
+ },
+)
diff --git a/docs/quick_tutorial/forms.rst b/docs/quick_tutorial/forms.rst
index be745764b..3cd1e26aa 100644
--- a/docs/quick_tutorial/forms.rst
+++ b/docs/quick_tutorial/forms.rst
@@ -31,77 +31,72 @@ Objectives
Steps
=====
-#. First we copy the results of the ``view_classes`` step:
+#. First we copy the results of the ``view_classes`` step:
- .. code-block:: bash
+ .. code-block:: bash
- cd ..; cp -r view_classes forms; cd forms
+ cd ..; cp -r view_classes forms; cd forms
-#. Let's edit ``forms/setup.py`` to declare a dependency on Deform (which then
- pulls in Colander as a dependency:
+#. Let's edit ``forms/setup.py`` to declare a dependency on Deform, which in turn pulls in Colander as a dependency:
- .. literalinclude:: forms/setup.py
- :emphasize-lines: 4
- :linenos:
+ .. literalinclude:: forms/setup.py
+ :emphasize-lines: 6
+ :linenos:
-#. We can now install our project in development mode:
+#. We can now install our project in development mode:
- .. code-block:: bash
+ .. code-block:: bash
- $VENV/bin/pip install -e .
+ $VENV/bin/pip install -e .
-#. Register a static view in ``forms/tutorial/__init__.py`` for Deform's CSS,
- JavaScript, etc., as well as our demo wiki page's views:
+#. Register a static view in ``forms/tutorial/__init__.py`` for Deform's CSS, JavaScript, etc., as well as our demo wiki page's views:
- .. literalinclude:: forms/tutorial/__init__.py
- :linenos:
+ .. literalinclude:: forms/tutorial/__init__.py
+ :linenos:
-#. Implement the new views, as well as the form schemas and some dummy data, in
- ``forms/tutorial/views.py``:
+#. Implement the new views, as well as the form schemas and some dummy data, in ``forms/tutorial/views.py``:
- .. literalinclude:: forms/tutorial/views.py
- :linenos:
+ .. literalinclude:: forms/tutorial/views.py
+ :linenos:
-#. A template for the top of the "wiki" in ``forms/tutorial/wiki_view.pt``:
+#. A template for the top of the "wiki" in ``forms/tutorial/wiki_view.pt``:
- .. literalinclude:: forms/tutorial/wiki_view.pt
- :language: html
- :linenos:
+ .. literalinclude:: forms/tutorial/wiki_view.pt
+ :language: html
+ :linenos:
-#. Another template for adding/editing in
- ``forms/tutorial/wikipage_addedit.pt``:
+#. Another template for adding/editing in ``forms/tutorial/wikipage_addedit.pt``:
- .. literalinclude:: forms/tutorial/wikipage_addedit.pt
- :language: html
- :linenos:
+ .. literalinclude:: forms/tutorial/wikipage_addedit.pt
+ :language: html
+ :linenos:
-#. Add a template at ``forms/tutorial/wikipage_view.pt`` for viewing a wiki
- page:
+#. Add a template at ``forms/tutorial/wikipage_view.pt`` for viewing a wiki page:
- .. literalinclude:: forms/tutorial/wikipage_view.pt
- :language: html
- :linenos:
+ .. literalinclude:: forms/tutorial/wikipage_view.pt
+ :language: html
+ :linenos:
-#. Our tests in ``forms/tutorial/tests.py`` don't run, so let's modify them:
+#. Our tests in ``forms/tutorial/tests.py`` don't run, so let's modify them:
- .. literalinclude:: forms/tutorial/tests.py
- :linenos:
+ .. literalinclude:: forms/tutorial/tests.py
+ :linenos:
-#. Run the tests:
+#. Run the tests:
- .. code-block:: bash
+ .. code-block:: bash
- $VENV/bin/py.test tutorial/tests.py -q
- ..
- 2 passed in 0.45 seconds
+ $VENV/bin/pytest tutorial/tests.py -q
+ ..
+ 6 passed in 0.81 seconds
-#. Run your Pyramid application with:
+#. Run your Pyramid application with:
- .. code-block:: bash
+ .. code-block:: bash
- $VENV/bin/pserve development.ini --reload
+ $VENV/bin/pserve development.ini --reload
-#. Open http://localhost:6543/ in a browser.
+#. Open http://localhost:6543/ in a browser.
Analysis
diff --git a/docs/quick_tutorial/forms/setup.py b/docs/quick_tutorial/forms/setup.py
index 968889e74..0e9ea72bc 100644
--- a/docs/quick_tutorial/forms/setup.py
+++ b/docs/quick_tutorial/forms/setup.py
@@ -1,5 +1,7 @@
from setuptools import setup
+# List of dependencies installed via `pip install -e .`
+# by virtue of the Setuptools `install_requires` value below.
requires = [
'deform',
'pyramid',
@@ -7,10 +9,24 @@ requires = [
'waitress',
]
-setup(name='tutorial',
- install_requires=requires,
- entry_points="""\
- [paste.app_factory]
- main = tutorial:main
- """,
+# List of dependencies installed via `pip install -e ".[dev]"`
+# by virtue of the Setuptools `extras_require` value in the Python
+# dictionary below.
+dev_requires = [
+ 'pyramid_debugtoolbar',
+ 'pytest',
+ 'webtest',
+]
+
+setup(
+ name='tutorial',
+ install_requires=requires,
+ extras_require={
+ 'dev': dev_requires,
+ },
+ entry_points={
+ 'paste.app_factory': [
+ 'main = tutorial:main'
+ ],
+ },
)
diff --git a/docs/quick_tutorial/forms/tutorial/tests.py b/docs/quick_tutorial/forms/tutorial/tests.py
index 5a2c40904..f0e39aa38 100644
--- a/docs/quick_tutorial/forms/tutorial/tests.py
+++ b/docs/quick_tutorial/forms/tutorial/tests.py
@@ -34,3 +34,33 @@ class TutorialFunctionalTests(unittest.TestCase):
def test_home(self):
res = self.testapp.get('/', status=200)
self.assertIn(b'<title>Wiki: View</title>', res.body)
+
+ def test_add_page(self):
+ res = self.testapp.get('/add', status=200)
+ self.assertIn(b'<h1>Wiki</h1>', res.body)
+
+ def test_edit_page(self):
+ res = self.testapp.get('/101/edit', status=200)
+ self.assertIn(b'<h1>Wiki</h1>', res.body)
+
+ def test_post_wiki(self):
+ self.testapp.post('/add', {
+ "title": "New Title",
+ "body": "<p>New Body</p>",
+ "submit": "submit"
+ }, status=302)
+
+ res = self.testapp.get('/103', status=200)
+ self.assertIn(b'<h1>New Title</h1>', res.body)
+ self.assertIn(b'<p>New Body</p>', res.body)
+
+ def test_edit_wiki(self):
+ self.testapp.post('/102/edit', {
+ "title": "New Title",
+ "body": "<p>New Body</p>",
+ "submit": "submit"
+ }, status=302)
+
+ res = self.testapp.get('/102', status=200)
+ self.assertIn(b'<h1>New Title</h1>', res.body)
+ self.assertIn(b'<p>New Body</p>', res.body)
diff --git a/docs/quick_tutorial/functional_testing.rst b/docs/quick_tutorial/functional_testing.rst
index fa56b4589..054d03761 100644
--- a/docs/quick_tutorial/functional_testing.rst
+++ b/docs/quick_tutorial/functional_testing.rst
@@ -31,31 +31,40 @@ Objectives
Steps
=====
-#. First we copy the results of the previous step, as well as install the
- ``webtest`` package:
+#. First we copy the results of the previous step.
- .. code-block:: bash
+ .. code-block:: bash
- cd ..; cp -r unit_testing functional_testing; cd functional_testing
- $VENV/bin/pip install -e .
- $VENV/bin/pip install webtest
+ cd ..; cp -r unit_testing functional_testing; cd functional_testing
-#. Let's extend ``functional_testing/tutorial/tests.py`` to include a
- functional test:
+#. Add ``webtest`` to our project's dependencies in ``setup.py`` as a :term:`Setuptools` "extra":
- .. literalinclude:: functional_testing/tutorial/tests.py
- :linenos:
+ .. literalinclude:: functional_testing/setup.py
+ :language: python
+ :linenos:
+ :emphasize-lines: 16
- Be sure this file is not executable, or ``pytest`` may not include your
- tests.
+#. Install our project and its newly added dependency.
+ Note that we use the extra specifier ``[dev]`` to install testing requirements for development and surround it and the period with double quote marks.
+
+ .. code-block:: bash
+
+ $VENV/bin/pip install -e ".[dev]"
+
+#. Let's extend ``functional_testing/tutorial/tests.py`` to include a functional test:
+
+ .. literalinclude:: functional_testing/tutorial/tests.py
+ :linenos:
+
+ Be sure this file is not executable, or ``pytest`` may not include your tests.
-#. Now run the tests:
+#. Now run the tests:
- .. code-block:: bash
+ .. code-block:: bash
- $VENV/bin/py.test tutorial/tests.py -q
- ..
- 2 passed in 0.25 seconds
+ $VENV/bin/pytest tutorial/tests.py -q
+ ..
+ 2 passed in 0.25 seconds
Analysis
diff --git a/docs/quick_tutorial/functional_testing/setup.py b/docs/quick_tutorial/functional_testing/setup.py
index a93cf6a73..a0fa8217c 100644
--- a/docs/quick_tutorial/functional_testing/setup.py
+++ b/docs/quick_tutorial/functional_testing/setup.py
@@ -1,14 +1,30 @@
from setuptools import setup
+# List of dependencies installed via `pip install -e .`
+# by virtue of the Setuptools `install_requires` value below.
requires = [
'pyramid',
'waitress',
]
-setup(name='tutorial',
- install_requires=requires,
- entry_points="""\
- [paste.app_factory]
- main = tutorial:main
- """,
-) \ No newline at end of file
+# List of dependencies installed via `pip install -e ".[dev]"`
+# by virtue of the Setuptools `extras_require` value in the Python
+# dictionary below.
+dev_requires = [
+ 'pyramid_debugtoolbar',
+ 'pytest',
+ 'webtest',
+]
+
+setup(
+ name='tutorial',
+ install_requires=requires,
+ extras_require={
+ 'dev': dev_requires,
+ },
+ entry_points={
+ 'paste.app_factory': [
+ 'main = tutorial:main'
+ ],
+ },
+)
diff --git a/docs/quick_tutorial/ini.rst b/docs/quick_tutorial/ini.rst
index ce92914fe..0bb7da1ba 100644
--- a/docs/quick_tutorial/ini.rst
+++ b/docs/quick_tutorial/ini.rst
@@ -11,19 +11,16 @@ simpler, better application running.
Background
==========
-Pyramid has a first-class concept of :ref:`configuration <configuration_narr>`
-distinct from code. This approach is optional, but its presence makes it
-distinct from other Python web frameworks. It taps into Python's ``setuptools``
-library, which establishes conventions for installing and providing "entry
-points" for Python projects. Pyramid uses an entry point to let a Pyramid
-application know where to find the WSGI app.
+Pyramid has a first-class concept of :ref:`configuration <configuration_narr>` distinct from code.
+This approach is optional, but its presence makes it distinct from other Python web frameworks.
+It taps into Python's :term:`Setuptools` library, which establishes conventions for installing and providing ":term:`entry point`\ s" for Python projects.
+Pyramid uses an :term:`entry point` to let a Pyramid application know where to find the WSGI app.
Objectives
==========
-- Modify our ``setup.py`` to have an entry point telling Pyramid the location
- of the WSGI app.
+- Modify our ``setup.py`` to have an :term:`entry point` telling Pyramid the location of the WSGI app.
- Create an application driven by an ``.ini`` file.
@@ -35,50 +32,48 @@ Objectives
Steps
=====
-#. First we copy the results of the previous step:
+#. First we copy the results of the previous step:
- .. code-block:: bash
+ .. code-block:: bash
- cd ..; cp -r package ini; cd ini
+ cd ..; cp -r package ini; cd ini
-#. Our ``ini/setup.py`` needs a setuptools "entry point" in the ``setup()``
- function:
+#. Our ``ini/setup.py`` needs a :term:`Setuptools` :term:`entry point` in the ``setup()`` function:
- .. literalinclude:: ini/setup.py
- :linenos:
+ .. literalinclude:: ini/setup.py
+ :linenos:
+ :emphasize-lines: 13-17
-#. We can now install our project, thus generating (or re-generating) an "egg"
- at ``ini/tutorial.egg-info``:
+#. We can now install our project, thus generating (or re-generating) an "egg" at ``ini/tutorial.egg-info``:
- .. code-block:: bash
+ .. code-block:: bash
- $VENV/bin/pip install -e .
+ $VENV/bin/pip install -e .
-#. Let's make a file ``ini/development.ini`` for our configuration:
+#. Let's make a file ``ini/development.ini`` for our configuration:
- .. literalinclude:: ini/development.ini
- :language: ini
- :linenos:
+ .. literalinclude:: ini/development.ini
+ :language: ini
+ :linenos:
-#. We can refactor our startup code from the previous step's ``app.py`` into
- ``ini/tutorial/__init__.py``:
+#. We can refactor our startup code from the previous step's ``app.py`` into ``ini/tutorial/__init__.py``:
- .. literalinclude:: ini/tutorial/__init__.py
- :linenos:
+ .. literalinclude:: ini/tutorial/__init__.py
+ :linenos:
-#. Now that ``ini/tutorial/app.py`` isn't used, let's remove it:
+#. Now that ``ini/tutorial/app.py`` isn't used, let's remove it:
- .. code-block:: bash
+ .. code-block:: bash
- rm tutorial/app.py
+ rm tutorial/app.py
-#. Run your Pyramid application with:
+#. Run your Pyramid application with:
- .. code-block:: bash
+ .. code-block:: bash
- $VENV/bin/pserve development.ini --reload
+ $VENV/bin/pserve development.ini --reload
-#. Open http://localhost:6543/.
+#. Open http://localhost:6543/.
Analysis
========
@@ -89,8 +84,7 @@ application. Processing then proceeds as described in the Pyramid chapter on
- ``pserve`` looks for ``[app:main]`` and finds ``use = egg:tutorial``.
-- The projects's ``setup.py`` has defined an "entry point" (lines 10-13) for the
- project's "main" entry point of ``tutorial:main``.
+- The projects's ``setup.py`` has defined an :term:`entry point` (lines 10-13) for the project's "main" :term:`entry point` of ``tutorial:main``.
- The ``tutorial`` package's ``__init__`` has a ``main`` function.
@@ -133,8 +127,7 @@ Extra credit
#. Can we have multiple ``.ini`` configuration files for a project? Why might
you want to do that?
-#. The entry point in ``setup.py`` didn't mention ``__init__.py`` when it
- declared ``tutorial:main`` function. Why not?
+#. The :term:`entry point` in ``setup.py`` didn't mention ``__init__.py`` when it declared ``tutorial:main`` function. Why not?
#. What is the purpose of ``**settings``? What does the ``**`` signify?
diff --git a/docs/quick_tutorial/ini/setup.py b/docs/quick_tutorial/ini/setup.py
index a93cf6a73..f1d06fe75 100644
--- a/docs/quick_tutorial/ini/setup.py
+++ b/docs/quick_tutorial/ini/setup.py
@@ -1,14 +1,18 @@
from setuptools import setup
+# List of dependencies installed via `pip install -e .`
+# by virtue of the Setuptools `install_requires` value below.
requires = [
'pyramid',
'waitress',
]
-setup(name='tutorial',
- install_requires=requires,
- entry_points="""\
- [paste.app_factory]
- main = tutorial:main
- """,
-) \ No newline at end of file
+setup(
+ name='tutorial',
+ install_requires=requires,
+ entry_points={
+ 'paste.app_factory': [
+ 'main = tutorial:main'
+ ],
+ },
+)
diff --git a/docs/quick_tutorial/jinja2.rst b/docs/quick_tutorial/jinja2.rst
index 87122a374..ed9acd955 100644
--- a/docs/quick_tutorial/jinja2.rst
+++ b/docs/quick_tutorial/jinja2.rst
@@ -22,45 +22,55 @@ Objectives
Steps
=====
-#. In this step let's start by copying the ``view_class`` step's directory,
- and then installing the ``pyramid_jinja2`` add-on.
+#. In this step let's start by copying the ``view_class`` step's directory from a few steps ago.
- .. code-block:: bash
+ .. code-block:: bash
- cd ..; cp -r view_classes jinja2; cd jinja2
- $VENV/bin/pip install -e .
- $VENV/bin/pip install pyramid_jinja2
+ cd ..; cp -r view_classes jinja2; cd jinja2
-#. We need to include ``pyramid_jinja2`` in ``jinja2/tutorial/__init__.py``:
+#. Add ``pyramid_jinja2`` to our project's dependencies in ``setup.py``:
- .. literalinclude:: jinja2/tutorial/__init__.py
- :linenos:
+ .. literalinclude:: jinja2/setup.py
+ :language: python
+ :linenos:
+ :emphasize-lines: 8
-#. Our ``jinja2/tutorial/views.py`` simply changes its ``renderer``:
+#. Install our project and its newly added dependency.
- .. literalinclude:: jinja2/tutorial/views.py
- :linenos:
+ .. code-block:: bash
-#. Add ``jinja2/tutorial/home.jinja2`` as a template:
+ $VENV/bin/pip install -e .
- .. literalinclude:: jinja2/tutorial/home.jinja2
- :language: html
+#. We need to include ``pyramid_jinja2`` in ``jinja2/tutorial/__init__.py``:
-#. Now run the tests:
+ .. literalinclude:: jinja2/tutorial/__init__.py
+ :linenos:
- .. code-block:: bash
+#. Our ``jinja2/tutorial/views.py`` simply changes its ``renderer``:
- $VENV/bin/py.test tutorial/tests.py -q
- ....
- 4 passed in 0.40 seconds
+ .. literalinclude:: jinja2/tutorial/views.py
+ :linenos:
-#. Run your Pyramid application with:
+#. Add ``jinja2/tutorial/home.jinja2`` as a template:
- .. code-block:: bash
+ .. literalinclude:: jinja2/tutorial/home.jinja2
+ :language: html
- $VENV/bin/pserve development.ini --reload
+#. Now run the tests:
-#. Open http://localhost:6543/ in your browser.
+ .. code-block:: bash
+
+ $VENV/bin/pytest tutorial/tests.py -q
+ ....
+ 4 passed in 0.40 seconds
+
+#. Run your Pyramid application with:
+
+ .. code-block:: bash
+
+ $VENV/bin/pserve development.ini --reload
+
+#. Open http://localhost:6543/ in your browser.
Analysis
diff --git a/docs/quick_tutorial/jinja2/setup.py b/docs/quick_tutorial/jinja2/setup.py
index a93cf6a73..ea2c59045 100644
--- a/docs/quick_tutorial/jinja2/setup.py
+++ b/docs/quick_tutorial/jinja2/setup.py
@@ -1,14 +1,32 @@
from setuptools import setup
+# List of dependencies installed via `pip install -e .`
+# by virtue of the Setuptools `install_requires` value below.
requires = [
'pyramid',
+ 'pyramid_chameleon',
+ 'pyramid_jinja2',
'waitress',
]
-setup(name='tutorial',
- install_requires=requires,
- entry_points="""\
- [paste.app_factory]
- main = tutorial:main
- """,
-) \ No newline at end of file
+# List of dependencies installed via `pip install -e ".[dev]"`
+# by virtue of the Setuptools `extras_require` value in the Python
+# dictionary below.
+dev_requires = [
+ 'pyramid_debugtoolbar',
+ 'pytest',
+ 'webtest',
+]
+
+setup(
+ name='tutorial',
+ install_requires=requires,
+ extras_require={
+ 'dev': dev_requires,
+ },
+ entry_points={
+ 'paste.app_factory': [
+ 'main = tutorial:main'
+ ],
+ },
+)
diff --git a/docs/quick_tutorial/json.rst b/docs/quick_tutorial/json.rst
index 98283424c..44d1de8cb 100644
--- a/docs/quick_tutorial/json.rst
+++ b/docs/quick_tutorial/json.rst
@@ -54,7 +54,7 @@ Steps
.. code-block:: bash
- $VENV/bin/py.test tutorial/tests.py -q
+ $VENV/bin/pytest tutorial/tests.py -q
.....
5 passed in 0.47 seconds
diff --git a/docs/quick_tutorial/json/setup.py b/docs/quick_tutorial/json/setup.py
index 744612371..e9c068a23 100644
--- a/docs/quick_tutorial/json/setup.py
+++ b/docs/quick_tutorial/json/setup.py
@@ -1,15 +1,31 @@
from setuptools import setup
+# List of dependencies installed via `pip install -e .`
+# by virtue of the Setuptools `install_requires` value below.
requires = [
'pyramid',
'pyramid_chameleon',
'waitress',
]
-setup(name='tutorial',
- install_requires=requires,
- entry_points="""\
- [paste.app_factory]
- main = tutorial:main
- """,
+# List of dependencies installed via `pip install -e ".[dev]"`
+# by virtue of the Setuptools `extras_require` value in the Python
+# dictionary below.
+dev_requires = [
+ 'pyramid_debugtoolbar',
+ 'pytest',
+ 'webtest',
+]
+
+setup(
+ name='tutorial',
+ install_requires=requires,
+ extras_require={
+ 'dev': dev_requires,
+ },
+ entry_points={
+ 'paste.app_factory': [
+ 'main = tutorial:main'
+ ],
+ },
)
diff --git a/docs/quick_tutorial/logging.rst b/docs/quick_tutorial/logging.rst
index ccbb7970f..f4a368bfa 100644
--- a/docs/quick_tutorial/logging.rst
+++ b/docs/quick_tutorial/logging.rst
@@ -54,7 +54,7 @@ Steps
.. code-block:: bash
- $VENV/bin/py.test tutorial/tests.py -q
+ $VENV/bin/pytest tutorial/tests.py -q
....
4 passed in 0.41 seconds
diff --git a/docs/quick_tutorial/logging/setup.py b/docs/quick_tutorial/logging/setup.py
index 744612371..e9c068a23 100644
--- a/docs/quick_tutorial/logging/setup.py
+++ b/docs/quick_tutorial/logging/setup.py
@@ -1,15 +1,31 @@
from setuptools import setup
+# List of dependencies installed via `pip install -e .`
+# by virtue of the Setuptools `install_requires` value below.
requires = [
'pyramid',
'pyramid_chameleon',
'waitress',
]
-setup(name='tutorial',
- install_requires=requires,
- entry_points="""\
- [paste.app_factory]
- main = tutorial:main
- """,
+# List of dependencies installed via `pip install -e ".[dev]"`
+# by virtue of the Setuptools `extras_require` value in the Python
+# dictionary below.
+dev_requires = [
+ 'pyramid_debugtoolbar',
+ 'pytest',
+ 'webtest',
+]
+
+setup(
+ name='tutorial',
+ install_requires=requires,
+ extras_require={
+ 'dev': dev_requires,
+ },
+ entry_points={
+ 'paste.app_factory': [
+ 'main = tutorial:main'
+ ],
+ },
)
diff --git a/docs/quick_tutorial/more_view_classes.rst b/docs/quick_tutorial/more_view_classes.rst
index 15452e9ae..b7e724dcf 100644
--- a/docs/quick_tutorial/more_view_classes.rst
+++ b/docs/quick_tutorial/more_view_classes.rst
@@ -53,7 +53,7 @@ Objectives
Steps
=====
-#. First we copy the results of the previous step:
+#. First we copy the results of the ``templating`` step:
.. code-block:: bash
@@ -105,7 +105,7 @@ Steps
.. code-block:: bash
- $VENV/bin/py.test tutorial/tests.py -q
+ $VENV/bin/pytest tutorial/tests.py -q
..
2 passed in 0.40 seconds
diff --git a/docs/quick_tutorial/more_view_classes/setup.py b/docs/quick_tutorial/more_view_classes/setup.py
index 744612371..e9c068a23 100644
--- a/docs/quick_tutorial/more_view_classes/setup.py
+++ b/docs/quick_tutorial/more_view_classes/setup.py
@@ -1,15 +1,31 @@
from setuptools import setup
+# List of dependencies installed via `pip install -e .`
+# by virtue of the Setuptools `install_requires` value below.
requires = [
'pyramid',
'pyramid_chameleon',
'waitress',
]
-setup(name='tutorial',
- install_requires=requires,
- entry_points="""\
- [paste.app_factory]
- main = tutorial:main
- """,
+# List of dependencies installed via `pip install -e ".[dev]"`
+# by virtue of the Setuptools `extras_require` value in the Python
+# dictionary below.
+dev_requires = [
+ 'pyramid_debugtoolbar',
+ 'pytest',
+ 'webtest',
+]
+
+setup(
+ name='tutorial',
+ install_requires=requires,
+ extras_require={
+ 'dev': dev_requires,
+ },
+ entry_points={
+ 'paste.app_factory': [
+ 'main = tutorial:main'
+ ],
+ },
)
diff --git a/docs/quick_tutorial/package/setup.py b/docs/quick_tutorial/package/setup.py
index 77fedee2d..910c552ad 100644
--- a/docs/quick_tutorial/package/setup.py
+++ b/docs/quick_tutorial/package/setup.py
@@ -1,10 +1,13 @@
from setuptools import setup
+# List of dependencies installed via `pip install -e .`
+# by virtue of the Setuptools `install_requires` value below.
requires = [
'pyramid',
'waitress',
]
-setup(name='tutorial',
- install_requires=requires,
+setup(
+ name='tutorial',
+ install_requires=requires,
)
diff --git a/docs/quick_tutorial/request_response.rst b/docs/quick_tutorial/request_response.rst
index 098753820..f7753f222 100644
--- a/docs/quick_tutorial/request_response.rst
+++ b/docs/quick_tutorial/request_response.rst
@@ -61,7 +61,7 @@ Steps
.. code-block:: bash
- $VENV/bin/py.test tutorial/tests.py -q
+ $VENV/bin/pytest tutorial/tests.py -q
.....
5 passed in 0.30 seconds
diff --git a/docs/quick_tutorial/request_response/setup.py b/docs/quick_tutorial/request_response/setup.py
index a93cf6a73..e9c068a23 100644
--- a/docs/quick_tutorial/request_response/setup.py
+++ b/docs/quick_tutorial/request_response/setup.py
@@ -1,14 +1,31 @@
from setuptools import setup
+# List of dependencies installed via `pip install -e .`
+# by virtue of the Setuptools `install_requires` value below.
requires = [
'pyramid',
+ 'pyramid_chameleon',
'waitress',
]
-setup(name='tutorial',
- install_requires=requires,
- entry_points="""\
- [paste.app_factory]
- main = tutorial:main
- """,
-) \ No newline at end of file
+# List of dependencies installed via `pip install -e ".[dev]"`
+# by virtue of the Setuptools `extras_require` value in the Python
+# dictionary below.
+dev_requires = [
+ 'pyramid_debugtoolbar',
+ 'pytest',
+ 'webtest',
+]
+
+setup(
+ name='tutorial',
+ install_requires=requires,
+ extras_require={
+ 'dev': dev_requires,
+ },
+ entry_points={
+ 'paste.app_factory': [
+ 'main = tutorial:main'
+ ],
+ },
+)
diff --git a/docs/quick_tutorial/retail_forms/setup.py b/docs/quick_tutorial/retail_forms/setup.py
index 968889e74..dda0a2cc4 100644
--- a/docs/quick_tutorial/retail_forms/setup.py
+++ b/docs/quick_tutorial/retail_forms/setup.py
@@ -1,5 +1,7 @@
from setuptools import setup
+# List of dependencies installed via `pip install -e .`
+# by virtue of the Setuptools `install_requires` value below.
requires = [
'deform',
'pyramid',
@@ -7,10 +9,12 @@ requires = [
'waitress',
]
-setup(name='tutorial',
- install_requires=requires,
- entry_points="""\
- [paste.app_factory]
- main = tutorial:main
- """,
+setup(
+ name='tutorial',
+ install_requires=requires,
+ entry_points={
+ 'paste.app_factory': [
+ 'main = tutorial:main'
+ ],
+ },
)
diff --git a/docs/quick_tutorial/routing.rst b/docs/quick_tutorial/routing.rst
index 0384892b2..a6538a75f 100644
--- a/docs/quick_tutorial/routing.rst
+++ b/docs/quick_tutorial/routing.rst
@@ -79,7 +79,7 @@ Steps
.. code-block:: bash
- $VENV/bin/py.test tutorial/tests.py -q
+ $VENV/bin/pytest tutorial/tests.py -q
..
2 passed in 0.39 seconds
diff --git a/docs/quick_tutorial/routing/setup.py b/docs/quick_tutorial/routing/setup.py
index 744612371..e9c068a23 100644
--- a/docs/quick_tutorial/routing/setup.py
+++ b/docs/quick_tutorial/routing/setup.py
@@ -1,15 +1,31 @@
from setuptools import setup
+# List of dependencies installed via `pip install -e .`
+# by virtue of the Setuptools `install_requires` value below.
requires = [
'pyramid',
'pyramid_chameleon',
'waitress',
]
-setup(name='tutorial',
- install_requires=requires,
- entry_points="""\
- [paste.app_factory]
- main = tutorial:main
- """,
+# List of dependencies installed via `pip install -e ".[dev]"`
+# by virtue of the Setuptools `extras_require` value in the Python
+# dictionary below.
+dev_requires = [
+ 'pyramid_debugtoolbar',
+ 'pytest',
+ 'webtest',
+]
+
+setup(
+ name='tutorial',
+ install_requires=requires,
+ extras_require={
+ 'dev': dev_requires,
+ },
+ entry_points={
+ 'paste.app_factory': [
+ 'main = tutorial:main'
+ ],
+ },
)
diff --git a/docs/quick_tutorial/sessions.rst b/docs/quick_tutorial/sessions.rst
index d67a5063a..8a67d6a0f 100644
--- a/docs/quick_tutorial/sessions.rst
+++ b/docs/quick_tutorial/sessions.rst
@@ -60,7 +60,7 @@ Steps
.. code-block:: bash
- $VENV/bin/py.test tutorial/tests.py -q
+ $VENV/bin/pytest tutorial/tests.py -q
....
4 passed in 0.42 seconds
diff --git a/docs/quick_tutorial/sessions/setup.py b/docs/quick_tutorial/sessions/setup.py
index 744612371..e9c068a23 100644
--- a/docs/quick_tutorial/sessions/setup.py
+++ b/docs/quick_tutorial/sessions/setup.py
@@ -1,15 +1,31 @@
from setuptools import setup
+# List of dependencies installed via `pip install -e .`
+# by virtue of the Setuptools `install_requires` value below.
requires = [
'pyramid',
'pyramid_chameleon',
'waitress',
]
-setup(name='tutorial',
- install_requires=requires,
- entry_points="""\
- [paste.app_factory]
- main = tutorial:main
- """,
+# List of dependencies installed via `pip install -e ".[dev]"`
+# by virtue of the Setuptools `extras_require` value in the Python
+# dictionary below.
+dev_requires = [
+ 'pyramid_debugtoolbar',
+ 'pytest',
+ 'webtest',
+]
+
+setup(
+ name='tutorial',
+ install_requires=requires,
+ extras_require={
+ 'dev': dev_requires,
+ },
+ entry_points={
+ 'paste.app_factory': [
+ 'main = tutorial:main'
+ ],
+ },
)
diff --git a/docs/quick_tutorial/static_assets.rst b/docs/quick_tutorial/static_assets.rst
index 7a6b5dac3..567328307 100644
--- a/docs/quick_tutorial/static_assets.rst
+++ b/docs/quick_tutorial/static_assets.rst
@@ -54,7 +54,7 @@ Steps
.. code-block:: bash
- $VENV/bin/py.test tutorial/tests.py -q
+ $VENV/bin/pytest tutorial/tests.py -q
....
5 passed in 0.50 seconds
diff --git a/docs/quick_tutorial/static_assets/setup.py b/docs/quick_tutorial/static_assets/setup.py
index 744612371..e9c068a23 100644
--- a/docs/quick_tutorial/static_assets/setup.py
+++ b/docs/quick_tutorial/static_assets/setup.py
@@ -1,15 +1,31 @@
from setuptools import setup
+# List of dependencies installed via `pip install -e .`
+# by virtue of the Setuptools `install_requires` value below.
requires = [
'pyramid',
'pyramid_chameleon',
'waitress',
]
-setup(name='tutorial',
- install_requires=requires,
- entry_points="""\
- [paste.app_factory]
- main = tutorial:main
- """,
+# List of dependencies installed via `pip install -e ".[dev]"`
+# by virtue of the Setuptools `extras_require` value in the Python
+# dictionary below.
+dev_requires = [
+ 'pyramid_debugtoolbar',
+ 'pytest',
+ 'webtest',
+]
+
+setup(
+ name='tutorial',
+ install_requires=requires,
+ extras_require={
+ 'dev': dev_requires,
+ },
+ entry_points={
+ 'paste.app_factory': [
+ 'main = tutorial:main'
+ ],
+ },
)
diff --git a/docs/quick_tutorial/templating.rst b/docs/quick_tutorial/templating.rst
index 3fbef699c..cef54fb6f 100644
--- a/docs/quick_tutorial/templating.rst
+++ b/docs/quick_tutorial/templating.rst
@@ -42,67 +42,64 @@ Objectives
Steps
=====
-#. Let's begin by using the previous package as a starting point for a new
- project:
+#. Let's begin by using the previous package as a starting point for a new project:
- .. code-block:: bash
+ .. code-block:: bash
- cd ..; cp -r views templating; cd templating
+ cd ..; cp -r views templating; cd templating
-#. This step depends on ``pyramid_chameleon``, so add it as a dependency in
- ``templating/setup.py``:
+#. This step depends on ``pyramid_chameleon``, so add it as a dependency in ``templating/setup.py``:
- .. literalinclude:: templating/setup.py
- :linenos:
+ .. literalinclude:: templating/setup.py
+ :linenos:
+ :emphasize-lines: 7
-#. Now we can activate the development-mode distribution:
+#. Now we can activate the development-mode distribution:
- .. code-block:: bash
+ .. code-block:: bash
- $VENV/bin/pip install -e .
+ $VENV/bin/pip install -e .
-#. We need to connect ``pyramid_chameleon`` as a renderer by making a call in
- the setup of ``templating/tutorial/__init__.py``:
+#. We need to connect ``pyramid_chameleon`` as a renderer by making a call in the setup of ``templating/tutorial/__init__.py``:
- .. literalinclude:: templating/tutorial/__init__.py
- :linenos:
+ .. literalinclude:: templating/tutorial/__init__.py
+ :linenos:
-#. Our ``templating/tutorial/views.py`` no longer has HTML in it:
+#. Our ``templating/tutorial/views.py`` no longer has HTML in it:
- .. literalinclude:: templating/tutorial/views.py
- :linenos:
+ .. literalinclude:: templating/tutorial/views.py
+ :linenos:
-#. Instead we have ``templating/tutorial/home.pt`` as a template:
+#. Instead we have ``templating/tutorial/home.pt`` as a template:
- .. literalinclude:: templating/tutorial/home.pt
- :language: html
+ .. literalinclude:: templating/tutorial/home.pt
+ :language: html
-#. For convenience, change ``templating/development.ini`` to reload templates
- automatically with ``pyramid.reload_templates``:
+#. For convenience, change ``templating/development.ini`` to reload templates automatically with ``pyramid.reload_templates``:
- .. literalinclude:: templating/development.ini
- :language: ini
+ .. literalinclude:: templating/development.ini
+ :language: ini
-#. Our unit tests in ``templating/tutorial/tests.py`` can focus on data:
+#. Our unit tests in ``templating/tutorial/tests.py`` can focus on data:
- .. literalinclude:: templating/tutorial/tests.py
- :linenos:
+ .. literalinclude:: templating/tutorial/tests.py
+ :linenos:
-#. Now run the tests:
+#. Now run the tests:
- .. code-block:: bash
+ .. code-block:: bash
- $VENV/bin/py.test tutorial/tests.py -q
- ....
- 4 passed in 0.46 seconds
+ $VENV/bin/pytest tutorial/tests.py -q
+ ....
+ 4 passed in 0.46 seconds
-#. Run your Pyramid application with:
+#. Run your Pyramid application with:
- .. code-block:: bash
+ .. code-block:: bash
- $VENV/bin/pserve development.ini --reload
+ $VENV/bin/pserve development.ini --reload
-#. Open http://localhost:6543/ and http://localhost:6543/howdy in your browser.
+#. Open http://localhost:6543/ and http://localhost:6543/howdy in your browser.
Analysis
diff --git a/docs/quick_tutorial/templating/setup.py b/docs/quick_tutorial/templating/setup.py
index 744612371..e9c068a23 100644
--- a/docs/quick_tutorial/templating/setup.py
+++ b/docs/quick_tutorial/templating/setup.py
@@ -1,15 +1,31 @@
from setuptools import setup
+# List of dependencies installed via `pip install -e .`
+# by virtue of the Setuptools `install_requires` value below.
requires = [
'pyramid',
'pyramid_chameleon',
'waitress',
]
-setup(name='tutorial',
- install_requires=requires,
- entry_points="""\
- [paste.app_factory]
- main = tutorial:main
- """,
+# List of dependencies installed via `pip install -e ".[dev]"`
+# by virtue of the Setuptools `extras_require` value in the Python
+# dictionary below.
+dev_requires = [
+ 'pyramid_debugtoolbar',
+ 'pytest',
+ 'webtest',
+]
+
+setup(
+ name='tutorial',
+ install_requires=requires,
+ extras_require={
+ 'dev': dev_requires,
+ },
+ entry_points={
+ 'paste.app_factory': [
+ 'main = tutorial:main'
+ ],
+ },
)
diff --git a/docs/quick_tutorial/tutorial_approach.rst b/docs/quick_tutorial/tutorial_approach.rst
index 7ef28bdb8..a16bce406 100644
--- a/docs/quick_tutorial/tutorial_approach.rst
+++ b/docs/quick_tutorial/tutorial_approach.rst
@@ -36,11 +36,13 @@ Each of the directories in our ``quick_tutorial`` workspace (e.g., ``request_res
project* (except as noted for the ``hello_world`` step). The ``tutorial``
directory is a *Python package*.
-For most steps you will copy the previous step's directory to a new directory, and change your working directory to the new directory, then install your project:
+For most steps you will copy an earlier step's directory to a new directory, change your working directory to the new directory, then install your project:
.. code-block:: bash
cd ..; cp -r package ini; cd ini
$VENV/bin/pip install -e .
-For a few steps, you won't copy the previous step's directory, but you will still need to install your project with ``$VENV/bin/pip install -e .``.
+For a few steps, you won't copy an earlier step's directory, but you will still need to install your project with ``$VENV/bin/pip install -e .``.
+
+Finally for a few steps, you might add a dependency to your project in its ``setup.py`` file, and then install both the dependency and the project with either ``$VENV/bin/pip install -e .`` or ``$VENV/bin/pip install -e ".[dev]"``.
diff --git a/docs/quick_tutorial/unit_testing.rst b/docs/quick_tutorial/unit_testing.rst
index 09e3ea197..654925347 100644
--- a/docs/quick_tutorial/unit_testing.rst
+++ b/docs/quick_tutorial/unit_testing.rst
@@ -43,28 +43,39 @@ Objectives
Steps
=====
-#. First we copy the results of the previous step, as well as install the
- ``pytest`` package:
+#. First we copy the results of the previous step.
- .. code-block:: bash
+ .. code-block:: bash
- cd ..; cp -r debugtoolbar unit_testing; cd unit_testing
- $VENV/bin/pip install -e .
- $VENV/bin/pip install pytest
+ cd ..; cp -r debugtoolbar unit_testing; cd unit_testing
-#. Now we write a simple unit test in ``unit_testing/tutorial/tests.py``:
+#. Add ``pytest`` to our project's dependencies in ``setup.py`` as a :term:`Setuptools` "extra":
- .. literalinclude:: unit_testing/tutorial/tests.py
- :linenos:
+ .. literalinclude:: unit_testing/setup.py
+ :language: python
+ :linenos:
+ :emphasize-lines: 15
-#. Now run the tests:
+#. Install our project and its newly added dependency.
+ Note that we use the extra specifier ``[dev]`` to install testing requirements for development and surround it and the period with double quote marks.
- .. code-block:: bash
+ .. code-block:: bash
+ $VENV/bin/pip install -e ".[dev]"
- $VENV/bin/py.test tutorial/tests.py -q
- .
- 1 passed in 0.14 seconds
+#. Now we write a simple unit test in ``unit_testing/tutorial/tests.py``:
+
+ .. literalinclude:: unit_testing/tutorial/tests.py
+ :linenos:
+
+#. Now run the tests:
+
+ .. code-block:: bash
+
+
+ $VENV/bin/pytest tutorial/tests.py -q
+ .
+ 1 passed in 0.14 seconds
Analysis
@@ -96,7 +107,7 @@ Extra credit
============
#. Change the test to assert that the response status code should be ``404``
- (meaning, not found). Run ``py.test`` again. Read the error report and see
+ (meaning, not found). Run ``pytest`` again. Read the error report and see
if you can decipher what it is telling you.
#. As a more realistic example, put the ``tests.py`` back as you found it, and
@@ -114,4 +125,4 @@ Extra credit
#. Why do we import the ``hello_world`` view function *inside* the
``test_hello_world`` method instead of at the top of the module?
-.. seealso:: See also :ref:`testing_chapter`
+.. seealso:: See also :ref:`testing_chapter` and `Setuptools Declaring "Extras" (optional features with their own dependencies) <https://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-extras-optional-features-with-their-own-dependencies>`_.
diff --git a/docs/quick_tutorial/unit_testing/setup.py b/docs/quick_tutorial/unit_testing/setup.py
index a93cf6a73..a5f8a250b 100644
--- a/docs/quick_tutorial/unit_testing/setup.py
+++ b/docs/quick_tutorial/unit_testing/setup.py
@@ -1,14 +1,29 @@
from setuptools import setup
+# List of dependencies installed via `pip install -e .`
+# by virtue of the Setuptools `install_requires` value below.
requires = [
'pyramid',
'waitress',
]
-setup(name='tutorial',
- install_requires=requires,
- entry_points="""\
- [paste.app_factory]
- main = tutorial:main
- """,
-) \ No newline at end of file
+# List of dependencies installed via `pip install -e ".[dev]"`
+# by virtue of the Setuptools `extras_require` value in the Python
+# dictionary below.
+dev_requires = [
+ 'pyramid_debugtoolbar',
+ 'pytest',
+]
+
+setup(
+ name='tutorial',
+ install_requires=requires,
+ extras_require={
+ 'dev': dev_requires,
+ },
+ entry_points={
+ 'paste.app_factory': [
+ 'main = tutorial:main'
+ ],
+ },
+)
diff --git a/docs/quick_tutorial/view_classes.rst b/docs/quick_tutorial/view_classes.rst
index fc7ba5125..1307857b7 100644
--- a/docs/quick_tutorial/view_classes.rst
+++ b/docs/quick_tutorial/view_classes.rst
@@ -37,41 +37,38 @@ Objectives
Steps
=====
-#. First we copy the results of the previous step:
+#. First we copy the results of the previous step:
- .. code-block:: bash
+ .. code-block:: bash
- cd ..; cp -r templating view_classes; cd view_classes
- $VENV/bin/pip install -e .
+ cd ..; cp -r templating view_classes; cd view_classes
+ $VENV/bin/pip install -e .
-#. Our ``view_classes/tutorial/views.py`` now has a view class with our two
- views:
+#. Our ``view_classes/tutorial/views.py`` now has a view class with our two views:
- .. literalinclude:: view_classes/tutorial/views.py
- :linenos:
+ .. literalinclude:: view_classes/tutorial/views.py
+ :linenos:
-#. Our unit tests in ``view_classes/tutorial/tests.py`` don't run, so let's
- modify them to import the view class, and make an instance before getting a
- response:
+#. Our unit tests in ``view_classes/tutorial/tests.py`` don't run, so let's modify them to import the view class, and make an instance before getting a response:
- .. literalinclude:: view_classes/tutorial/tests.py
- :linenos:
+ .. literalinclude:: view_classes/tutorial/tests.py
+ :linenos:
-#. Now run the tests:
+#. Now run the tests:
- .. code-block:: bash
+ .. code-block:: bash
- $VENV/bin/py.test tutorial/tests.py -q
- ....
- 4 passed in 0.34 seconds
+ $VENV/bin/pytest tutorial/tests.py -q
+ ....
+ 4 passed in 0.34 seconds
-#. Run your Pyramid application with:
+#. Run your Pyramid application with:
- .. code-block:: bash
+ .. code-block:: bash
- $VENV/bin/pserve development.ini --reload
+ $VENV/bin/pserve development.ini --reload
-#. Open http://localhost:6543/ and http://localhost:6543/howdy in your browser.
+#. Open http://localhost:6543/ and http://localhost:6543/howdy in your browser.
Analysis
diff --git a/docs/quick_tutorial/view_classes/setup.py b/docs/quick_tutorial/view_classes/setup.py
index 744612371..e9c068a23 100644
--- a/docs/quick_tutorial/view_classes/setup.py
+++ b/docs/quick_tutorial/view_classes/setup.py
@@ -1,15 +1,31 @@
from setuptools import setup
+# List of dependencies installed via `pip install -e .`
+# by virtue of the Setuptools `install_requires` value below.
requires = [
'pyramid',
'pyramid_chameleon',
'waitress',
]
-setup(name='tutorial',
- install_requires=requires,
- entry_points="""\
- [paste.app_factory]
- main = tutorial:main
- """,
+# List of dependencies installed via `pip install -e ".[dev]"`
+# by virtue of the Setuptools `extras_require` value in the Python
+# dictionary below.
+dev_requires = [
+ 'pyramid_debugtoolbar',
+ 'pytest',
+ 'webtest',
+]
+
+setup(
+ name='tutorial',
+ install_requires=requires,
+ extras_require={
+ 'dev': dev_requires,
+ },
+ entry_points={
+ 'paste.app_factory': [
+ 'main = tutorial:main'
+ ],
+ },
)
diff --git a/docs/quick_tutorial/views.rst b/docs/quick_tutorial/views.rst
index f7fa64719..45bc8518b 100644
--- a/docs/quick_tutorial/views.rst
+++ b/docs/quick_tutorial/views.rst
@@ -68,7 +68,7 @@ Steps
.. code-block:: bash
- $VENV/bin/py.test tutorial/tests.py -q
+ $VENV/bin/pytest tutorial/tests.py -q
....
4 passed in 0.28 seconds
diff --git a/docs/quick_tutorial/views/setup.py b/docs/quick_tutorial/views/setup.py
index a93cf6a73..a0fa8217c 100644
--- a/docs/quick_tutorial/views/setup.py
+++ b/docs/quick_tutorial/views/setup.py
@@ -1,14 +1,30 @@
from setuptools import setup
+# List of dependencies installed via `pip install -e .`
+# by virtue of the Setuptools `install_requires` value below.
requires = [
'pyramid',
'waitress',
]
-setup(name='tutorial',
- install_requires=requires,
- entry_points="""\
- [paste.app_factory]
- main = tutorial:main
- """,
-) \ No newline at end of file
+# List of dependencies installed via `pip install -e ".[dev]"`
+# by virtue of the Setuptools `extras_require` value in the Python
+# dictionary below.
+dev_requires = [
+ 'pyramid_debugtoolbar',
+ 'pytest',
+ 'webtest',
+]
+
+setup(
+ name='tutorial',
+ install_requires=requires,
+ extras_require={
+ 'dev': dev_requires,
+ },
+ entry_points={
+ 'paste.app_factory': [
+ 'main = tutorial:main'
+ ],
+ },
+)