From 50b8b42b7da17d20534e5fd21905c8fe56b68069 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sun, 7 Oct 2018 02:26:10 -0700 Subject: One more py.test to pytest --- docs/quick_tutorial/ini.rst | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'docs/quick_tutorial') diff --git a/docs/quick_tutorial/ini.rst b/docs/quick_tutorial/ini.rst index ce92914fe..6477b8e64 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 ` -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 ` 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 ":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. @@ -41,8 +38,7 @@ Steps 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 setuptools :term:`entry point` in the ``setup()`` function: .. literalinclude:: ini/setup.py :linenos: @@ -89,8 +85,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 +128,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? -- cgit v1.2.3 From 315e469540afeba4bffe7bafb1364a7bab059a24 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sun, 7 Oct 2018 02:40:23 -0700 Subject: Use proper case for Setuptools as a library name. Change Setuptools to a glossary term where useful. --- docs/quick_tutorial/ini.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docs/quick_tutorial') diff --git a/docs/quick_tutorial/ini.rst b/docs/quick_tutorial/ini.rst index 6477b8e64..90f66009c 100644 --- a/docs/quick_tutorial/ini.rst +++ b/docs/quick_tutorial/ini.rst @@ -13,7 +13,7 @@ Background Pyramid has a first-class concept of :ref:`configuration ` 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 ":term:`entry point`\ s" for Python projects. +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. @@ -38,7 +38,7 @@ Steps cd ..; cp -r package ini; cd ini -#. Our ``ini/setup.py`` needs a setuptools :term:`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: -- cgit v1.2.3 From 89ea49c213622ee0aea57138943f2b6d08307e70 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sun, 7 Oct 2018 02:55:06 -0700 Subject: Add pyramid_debugtoolbar to setup.py, and update narrative text accordingly. --- docs/quick_tutorial/debugtoolbar.rst | 69 +++++++++++++++++-------------- docs/quick_tutorial/debugtoolbar/setup.py | 1 + 2 files changed, 40 insertions(+), 30 deletions(-) (limited to 'docs/quick_tutorial') diff --git a/docs/quick_tutorial/debugtoolbar.rst b/docs/quick_tutorial/debugtoolbar.rst index b49dd1f97..c82a47340 100644 --- a/docs/quick_tutorial/debugtoolbar.rst +++ b/docs/quick_tutorial/debugtoolbar.rst @@ -32,30 +32,39 @@ 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 dependencies in ``setup.py``: - .. literalinclude:: debugtoolbar/development.ini - :language: ini - :linenos: + .. literalinclude:: debugtoolbar/setup.py + :language: python + :linenos: + :emphasize-lines: 5 -#. Run the WSGI application with: +#. Install our project and its newly added dependency. - .. code-block:: bash + .. code-block:: bash - $VENV/bin/pserve development.ini --reload + $VENV/bin/pip install -e . -#. 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 @@ -93,24 +102,24 @@ temporarily. 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 ``install_requires`` dependencies in ``debugtoolbar/setup.py`` because this tutorial is for development and educational purposes only. + In what cases would you *not* want to add ``pyramid_debugtoolbar`` to your dependencies? -#. 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('

Hello World!

') + def hello_world(request): + return Response('

Hello World!

') - to: + to: - .. code-block:: python + .. code-block:: python - def hello_world(request): - return xResponse('

Hello World!

') + def hello_world(request): + return xResponse('

Hello World!

') - 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..1c948f52b 100644 --- a/docs/quick_tutorial/debugtoolbar/setup.py +++ b/docs/quick_tutorial/debugtoolbar/setup.py @@ -2,6 +2,7 @@ from setuptools import setup requires = [ 'pyramid', + 'pyramid_debugtoolbar', 'waitress', ] -- cgit v1.2.3 From c2a76e4682cf4cfe81e98de874958ed885a4d159 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sun, 7 Oct 2018 03:02:39 -0700 Subject: PEP8 setup.py's --- docs/quick_tutorial/debugtoolbar/setup.py | 2 +- docs/quick_tutorial/ini/setup.py | 2 +- docs/quick_tutorial/package/setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'docs/quick_tutorial') diff --git a/docs/quick_tutorial/debugtoolbar/setup.py b/docs/quick_tutorial/debugtoolbar/setup.py index 1c948f52b..a947e20d8 100644 --- a/docs/quick_tutorial/debugtoolbar/setup.py +++ b/docs/quick_tutorial/debugtoolbar/setup.py @@ -12,4 +12,4 @@ setup(name='tutorial', [paste.app_factory] main = tutorial:main """, -) \ No newline at end of file + ) diff --git a/docs/quick_tutorial/ini/setup.py b/docs/quick_tutorial/ini/setup.py index a93cf6a73..7a2677ebd 100644 --- a/docs/quick_tutorial/ini/setup.py +++ b/docs/quick_tutorial/ini/setup.py @@ -11,4 +11,4 @@ setup(name='tutorial', [paste.app_factory] main = tutorial:main """, -) \ No newline at end of file + ) diff --git a/docs/quick_tutorial/package/setup.py b/docs/quick_tutorial/package/setup.py index 77fedee2d..a59527bf4 100644 --- a/docs/quick_tutorial/package/setup.py +++ b/docs/quick_tutorial/package/setup.py @@ -7,4 +7,4 @@ requires = [ setup(name='tutorial', install_requires=requires, -) + ) -- cgit v1.2.3 From 62bb826f56288b5a0c8dc05602ba2ebf2e4aa2e0 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sun, 7 Oct 2018 03:27:59 -0700 Subject: grammar --- docs/quick_tutorial/debugtoolbar.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs/quick_tutorial') diff --git a/docs/quick_tutorial/debugtoolbar.rst b/docs/quick_tutorial/debugtoolbar.rst index c82a47340..a13d153d8 100644 --- a/docs/quick_tutorial/debugtoolbar.rst +++ b/docs/quick_tutorial/debugtoolbar.rst @@ -38,7 +38,7 @@ Steps cd ..; cp -r ini debugtoolbar; cd debugtoolbar -#. Add ``pyramid_debugtoolbar`` to our project dependencies in ``setup.py``: +#. Add ``pyramid_debugtoolbar`` to our project's dependencies in ``setup.py``: .. literalinclude:: debugtoolbar/setup.py :language: python -- cgit v1.2.3 From 34a7a85436e1545356345affc21dd1a564635469 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sun, 7 Oct 2018 03:41:55 -0700 Subject: Make pytest an extra dependency in setup.py. Add paragraph on Setuptools extras. Carry forward previous setup.py changes. --- docs/quick_tutorial/unit_testing.rst | 46 +++++++++++++++++++++---------- docs/quick_tutorial/unit_testing/setup.py | 8 +++++- 2 files changed, 38 insertions(+), 16 deletions(-) (limited to 'docs/quick_tutorial') diff --git a/docs/quick_tutorial/unit_testing.rst b/docs/quick_tutorial/unit_testing.rst index 48cffd0e1..2e58ee8d9 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: 11-15 -#. Now run the tests: +#. Install our project and its newly added dependency. + Note that we use the extra specifier ``[test]`` to install testing requirements. - .. code-block:: bash + .. code-block:: bash + $VENV/bin/pip install -e .[test] - $VENV/bin/pytest 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 @@ -91,6 +102,11 @@ Note that our use of ``pyramid.testing.setUp()`` and necessary when your test needs to make use of the ``config`` object (it's a Configurator) to add stuff to the configuration state before calling the view. +Finally we've introduced the concept of :term:`Setuptools` extras. +These are optional or recommended features that may be installed with an "extras" specifier. +The specifier is the name of a key in a Python dictionary, and is surrounded by square brackets when invoked on the command line. +The value for the key is a Python list of dependencies. + Extra credit ============ @@ -114,4 +130,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) `_. diff --git a/docs/quick_tutorial/unit_testing/setup.py b/docs/quick_tutorial/unit_testing/setup.py index a93cf6a73..617c806aa 100644 --- a/docs/quick_tutorial/unit_testing/setup.py +++ b/docs/quick_tutorial/unit_testing/setup.py @@ -2,13 +2,19 @@ from setuptools import setup requires = [ 'pyramid', + 'pyramid_debugtoolbar', 'waitress', ] setup(name='tutorial', install_requires=requires, + extras_require={ + 'test': [ + 'pytest', + ], + }, entry_points="""\ [paste.app_factory] main = tutorial:main """, -) \ No newline at end of file + ) -- cgit v1.2.3 From 8998f6fbaf526c0c0fe4300ec78815c7badfa826 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sun, 7 Oct 2018 03:48:18 -0700 Subject: Make webtest an extra dependency in setup.py. Carry forward previous setup.py changes. --- docs/quick_tutorial/functional_testing.rst | 43 +++++++++++++++---------- docs/quick_tutorial/functional_testing/setup.py | 9 +++++- 2 files changed, 34 insertions(+), 18 deletions(-) (limited to 'docs/quick_tutorial') diff --git a/docs/quick_tutorial/functional_testing.rst b/docs/quick_tutorial/functional_testing.rst index 7c4dcee26..d3ada3793 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: 14 - 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 ``[test]`` to install testing requirements. + + .. code-block:: bash + + $VENV/bin/pip install -e .[test] + +#. 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/pytest 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..c0d3dee8f 100644 --- a/docs/quick_tutorial/functional_testing/setup.py +++ b/docs/quick_tutorial/functional_testing/setup.py @@ -2,13 +2,20 @@ from setuptools import setup requires = [ 'pyramid', + 'pyramid_debugtoolbar', 'waitress', ] setup(name='tutorial', install_requires=requires, + extras_require={ + 'test': [ + 'pytest', + 'webtest', + ], + }, entry_points="""\ [paste.app_factory] main = tutorial:main """, -) \ No newline at end of file + ) -- cgit v1.2.3 From 03966fb9850a46a51004d38499e158f3f2bbed2d Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sun, 7 Oct 2018 03:49:25 -0700 Subject: Carry forward previous setup.py changes. --- docs/quick_tutorial/views/setup.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'docs/quick_tutorial') diff --git a/docs/quick_tutorial/views/setup.py b/docs/quick_tutorial/views/setup.py index a93cf6a73..c0d3dee8f 100644 --- a/docs/quick_tutorial/views/setup.py +++ b/docs/quick_tutorial/views/setup.py @@ -2,13 +2,20 @@ from setuptools import setup requires = [ 'pyramid', + 'pyramid_debugtoolbar', 'waitress', ] setup(name='tutorial', install_requires=requires, + extras_require={ + 'test': [ + 'pytest', + 'webtest', + ], + }, entry_points="""\ [paste.app_factory] main = tutorial:main """, -) \ No newline at end of file + ) -- cgit v1.2.3 From 61a44f5a0969d6e61f98fef5ae8710c71e4cbaff Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sun, 7 Oct 2018 03:50:51 -0700 Subject: Carry forward previous setup.py changes. --- docs/quick_tutorial/templating/setup.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'docs/quick_tutorial') diff --git a/docs/quick_tutorial/templating/setup.py b/docs/quick_tutorial/templating/setup.py index 744612371..3ad7f004e 100644 --- a/docs/quick_tutorial/templating/setup.py +++ b/docs/quick_tutorial/templating/setup.py @@ -3,13 +3,20 @@ from setuptools import setup requires = [ 'pyramid', 'pyramid_chameleon', + 'pyramid_debugtoolbar', 'waitress', ] setup(name='tutorial', install_requires=requires, + extras_require={ + 'test': [ + 'pytest', + 'webtest', + ], + }, entry_points="""\ [paste.app_factory] main = tutorial:main """, -) + ) -- cgit v1.2.3 From 4e1175a5d701afdc98c09fd4dfe0b90db00a4e3a Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sun, 7 Oct 2018 03:59:53 -0700 Subject: Carry forward previous setup.py changes. --- docs/quick_tutorial/request_response/setup.py | 10 +++++++++- docs/quick_tutorial/routing/setup.py | 9 ++++++++- docs/quick_tutorial/view_classes/setup.py | 9 ++++++++- 3 files changed, 25 insertions(+), 3 deletions(-) (limited to 'docs/quick_tutorial') diff --git a/docs/quick_tutorial/request_response/setup.py b/docs/quick_tutorial/request_response/setup.py index a93cf6a73..3ad7f004e 100644 --- a/docs/quick_tutorial/request_response/setup.py +++ b/docs/quick_tutorial/request_response/setup.py @@ -2,13 +2,21 @@ from setuptools import setup requires = [ 'pyramid', + 'pyramid_chameleon', + 'pyramid_debugtoolbar', 'waitress', ] setup(name='tutorial', install_requires=requires, + extras_require={ + 'test': [ + 'pytest', + 'webtest', + ], + }, entry_points="""\ [paste.app_factory] main = tutorial:main """, -) \ No newline at end of file + ) diff --git a/docs/quick_tutorial/routing/setup.py b/docs/quick_tutorial/routing/setup.py index 744612371..3ad7f004e 100644 --- a/docs/quick_tutorial/routing/setup.py +++ b/docs/quick_tutorial/routing/setup.py @@ -3,13 +3,20 @@ from setuptools import setup requires = [ 'pyramid', 'pyramid_chameleon', + 'pyramid_debugtoolbar', 'waitress', ] setup(name='tutorial', install_requires=requires, + extras_require={ + 'test': [ + 'pytest', + 'webtest', + ], + }, entry_points="""\ [paste.app_factory] main = tutorial:main """, -) + ) diff --git a/docs/quick_tutorial/view_classes/setup.py b/docs/quick_tutorial/view_classes/setup.py index 744612371..3ad7f004e 100644 --- a/docs/quick_tutorial/view_classes/setup.py +++ b/docs/quick_tutorial/view_classes/setup.py @@ -3,13 +3,20 @@ from setuptools import setup requires = [ 'pyramid', 'pyramid_chameleon', + 'pyramid_debugtoolbar', 'waitress', ] setup(name='tutorial', install_requires=requires, + extras_require={ + 'test': [ + 'pytest', + 'webtest', + ], + }, entry_points="""\ [paste.app_factory] main = tutorial:main """, -) + ) -- cgit v1.2.3 From 84aa10ae8dbc46ccf8201e8c69efce132fcf7bed Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sun, 7 Oct 2018 04:00:19 -0700 Subject: Add pyramid_jinja2 as a requirement. Carry forward previous setup.py changes. --- docs/quick_tutorial/jinja2.rst | 58 ++++++++++++++++++++++--------------- docs/quick_tutorial/jinja2/setup.py | 11 ++++++- 2 files changed, 44 insertions(+), 25 deletions(-) (limited to 'docs/quick_tutorial') diff --git a/docs/quick_tutorial/jinja2.rst b/docs/quick_tutorial/jinja2.rst index 6c33e406e..23a9982d3 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: 7 -#. 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/pytest 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..86f177866 100644 --- a/docs/quick_tutorial/jinja2/setup.py +++ b/docs/quick_tutorial/jinja2/setup.py @@ -2,13 +2,22 @@ from setuptools import setup requires = [ 'pyramid', + 'pyramid_chameleon', + 'pyramid_debugtoolbar', + 'pyramid_jinja2', 'waitress', ] setup(name='tutorial', install_requires=requires, + extras_require={ + 'test': [ + 'pytest', + 'webtest', + ], + }, entry_points="""\ [paste.app_factory] main = tutorial:main """, -) \ No newline at end of file + ) -- cgit v1.2.3 From 3bb6f33b0401dd19f66ebd2c1c70d77e13886cf6 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sun, 7 Oct 2018 04:06:45 -0700 Subject: Carry forward previous setup.py changes. --- docs/quick_tutorial/json/setup.py | 9 ++++++++- docs/quick_tutorial/more_view_classes/setup.py | 9 ++++++++- docs/quick_tutorial/static_assets/setup.py | 9 ++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) (limited to 'docs/quick_tutorial') diff --git a/docs/quick_tutorial/json/setup.py b/docs/quick_tutorial/json/setup.py index 744612371..3ad7f004e 100644 --- a/docs/quick_tutorial/json/setup.py +++ b/docs/quick_tutorial/json/setup.py @@ -3,13 +3,20 @@ from setuptools import setup requires = [ 'pyramid', 'pyramid_chameleon', + 'pyramid_debugtoolbar', 'waitress', ] setup(name='tutorial', install_requires=requires, + extras_require={ + 'test': [ + 'pytest', + 'webtest', + ], + }, entry_points="""\ [paste.app_factory] main = tutorial:main """, -) + ) diff --git a/docs/quick_tutorial/more_view_classes/setup.py b/docs/quick_tutorial/more_view_classes/setup.py index 744612371..3ad7f004e 100644 --- a/docs/quick_tutorial/more_view_classes/setup.py +++ b/docs/quick_tutorial/more_view_classes/setup.py @@ -3,13 +3,20 @@ from setuptools import setup requires = [ 'pyramid', 'pyramid_chameleon', + 'pyramid_debugtoolbar', 'waitress', ] setup(name='tutorial', install_requires=requires, + extras_require={ + 'test': [ + 'pytest', + 'webtest', + ], + }, entry_points="""\ [paste.app_factory] main = tutorial:main """, -) + ) diff --git a/docs/quick_tutorial/static_assets/setup.py b/docs/quick_tutorial/static_assets/setup.py index 744612371..3ad7f004e 100644 --- a/docs/quick_tutorial/static_assets/setup.py +++ b/docs/quick_tutorial/static_assets/setup.py @@ -3,13 +3,20 @@ from setuptools import setup requires = [ 'pyramid', 'pyramid_chameleon', + 'pyramid_debugtoolbar', 'waitress', ] setup(name='tutorial', install_requires=requires, + extras_require={ + 'test': [ + 'pytest', + 'webtest', + ], + }, entry_points="""\ [paste.app_factory] main = tutorial:main """, -) + ) -- cgit v1.2.3 From db2ddd38c0e7c4c0ad88c076f6b76455bf0fedc9 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sun, 7 Oct 2018 04:07:03 -0700 Subject: Not previous step, but templating step --- docs/quick_tutorial/more_view_classes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs/quick_tutorial') diff --git a/docs/quick_tutorial/more_view_classes.rst b/docs/quick_tutorial/more_view_classes.rst index 684fb1c43..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 -- cgit v1.2.3 From e1c67ed23ae3d571c32ddef56c1cee7039cfd0f5 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sun, 7 Oct 2018 04:12:58 -0700 Subject: Carry forward previous setup.py changes. --- docs/quick_tutorial/forms/setup.py | 9 ++++++++- docs/quick_tutorial/logging/setup.py | 9 ++++++++- docs/quick_tutorial/sessions/setup.py | 9 ++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) (limited to 'docs/quick_tutorial') diff --git a/docs/quick_tutorial/forms/setup.py b/docs/quick_tutorial/forms/setup.py index 968889e74..e911d5bb8 100644 --- a/docs/quick_tutorial/forms/setup.py +++ b/docs/quick_tutorial/forms/setup.py @@ -4,13 +4,20 @@ requires = [ 'deform', 'pyramid', 'pyramid_chameleon', + 'pyramid_debugtoolbar', 'waitress', ] setup(name='tutorial', install_requires=requires, + extras_require={ + 'test': [ + 'pytest', + 'webtest', + ], + }, entry_points="""\ [paste.app_factory] main = tutorial:main """, -) + ) diff --git a/docs/quick_tutorial/logging/setup.py b/docs/quick_tutorial/logging/setup.py index 744612371..3ad7f004e 100644 --- a/docs/quick_tutorial/logging/setup.py +++ b/docs/quick_tutorial/logging/setup.py @@ -3,13 +3,20 @@ from setuptools import setup requires = [ 'pyramid', 'pyramid_chameleon', + 'pyramid_debugtoolbar', 'waitress', ] setup(name='tutorial', install_requires=requires, + extras_require={ + 'test': [ + 'pytest', + 'webtest', + ], + }, entry_points="""\ [paste.app_factory] main = tutorial:main """, -) + ) diff --git a/docs/quick_tutorial/sessions/setup.py b/docs/quick_tutorial/sessions/setup.py index 744612371..3ad7f004e 100644 --- a/docs/quick_tutorial/sessions/setup.py +++ b/docs/quick_tutorial/sessions/setup.py @@ -3,13 +3,20 @@ from setuptools import setup requires = [ 'pyramid', 'pyramid_chameleon', + 'pyramid_debugtoolbar', 'waitress', ] setup(name='tutorial', install_requires=requires, + extras_require={ + 'test': [ + 'pytest', + 'webtest', + ], + }, entry_points="""\ [paste.app_factory] main = tutorial:main """, -) + ) -- cgit v1.2.3 From 42aa12db0deec477bb3400c4a5bf213ece58cdf0 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sun, 7 Oct 2018 04:13:37 -0700 Subject: Fix grammar and standardize numbered list --- docs/quick_tutorial/forms.rst | 85 ++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 45 deletions(-) (limited to 'docs/quick_tutorial') diff --git a/docs/quick_tutorial/forms.rst b/docs/quick_tutorial/forms.rst index be0cb64ac..7d759b72d 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: 4 + :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/pytest tutorial/tests.py -q - .. - 6 passed in 0.81 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 -- cgit v1.2.3 From 57d49fbe4f507871e5baac30c2f393ec21801e17 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sun, 7 Oct 2018 04:22:36 -0700 Subject: Carry forward previous setup.py changes. Add emphasize lines to highlight what changed. Improve instructions for when to run `pip install -e .` Standardize numbered list format. --- docs/quick_tutorial/databases.rst | 120 +++++++++++++++------------------ docs/quick_tutorial/databases/setup.py | 9 ++- 2 files changed, 64 insertions(+), 65 deletions(-) (limited to 'docs/quick_tutorial') diff --git a/docs/quick_tutorial/databases.rst b/docs/quick_tutorial/databases.rst index dcf411d23..5ba23e937 100644 --- a/docs/quick_tutorial/databases.rst +++ b/docs/quick_tutorial/databases.rst @@ -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: 8-9, 11, 25-26 - .. 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', '

Root

') - 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', '

Root

') + 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 ``pytest``: +#. Run the tests in your package using ``pytest``: - .. code-block:: bash + .. code-block:: bash - $VENV/bin/pytest 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..29dede2af 100644 --- a/docs/quick_tutorial/databases/setup.py +++ b/docs/quick_tutorial/databases/setup.py @@ -4,6 +4,7 @@ requires = [ 'deform', 'pyramid', 'pyramid_chameleon', + 'pyramid_debugtoolbar', 'pyramid_tm', 'sqlalchemy', 'waitress', @@ -12,10 +13,16 @@ requires = [ setup(name='tutorial', install_requires=requires, + extras_require={ + 'test': [ + 'pytest', + 'webtest', + ], + }, entry_points="""\ [paste.app_factory] main = tutorial:main [console_scripts] initialize_tutorial_db = tutorial.initialize_db:main """, -) + ) -- cgit v1.2.3 From 97afb8f7520cbb24a7662bb92420e8c9fc70bda1 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sun, 7 Oct 2018 04:25:01 -0700 Subject: Carry forward previous setup.py changes. --- docs/quick_tutorial/authentication/setup.py | 9 ++++++++- docs/quick_tutorial/authorization/setup.py | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'docs/quick_tutorial') diff --git a/docs/quick_tutorial/authentication/setup.py b/docs/quick_tutorial/authentication/setup.py index a5117af5a..05104b158 100644 --- a/docs/quick_tutorial/authentication/setup.py +++ b/docs/quick_tutorial/authentication/setup.py @@ -4,13 +4,20 @@ requires = [ 'bcrypt', 'pyramid', 'pyramid_chameleon', + 'pyramid_debugtoolbar', 'waitress', ] setup(name='tutorial', install_requires=requires, + extras_require={ + 'test': [ + 'pytest', + 'webtest', + ], + }, 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..05104b158 100644 --- a/docs/quick_tutorial/authorization/setup.py +++ b/docs/quick_tutorial/authorization/setup.py @@ -4,13 +4,20 @@ requires = [ 'bcrypt', 'pyramid', 'pyramid_chameleon', + 'pyramid_debugtoolbar', 'waitress', ] setup(name='tutorial', install_requires=requires, + extras_require={ + 'test': [ + 'pytest', + 'webtest', + ], + }, entry_points="""\ [paste.app_factory] main = tutorial:main """, -) + ) -- cgit v1.2.3