From c1732b845348763cd514721126fc05e1531e44f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20F=C3=A9rotin?= Date: Fri, 6 May 2016 19:45:32 +0200 Subject: scaffolds: Allow `py.test` to be run on new project without specifying test module path. --- pyramid/scaffolds/alchemy/+dot+coveragerc_tmpl | 3 +++ pyramid/scaffolds/alchemy/pytest.ini_tmpl | 3 +++ pyramid/scaffolds/starter/+dot+coveragerc_tmpl | 3 +++ pyramid/scaffolds/starter/pytest.ini_tmpl | 3 +++ pyramid/scaffolds/zodb/+dot+coveragerc_tmpl | 3 +++ pyramid/scaffolds/zodb/pytest.ini_tmpl | 3 +++ 6 files changed, 18 insertions(+) create mode 100644 pyramid/scaffolds/alchemy/+dot+coveragerc_tmpl create mode 100644 pyramid/scaffolds/alchemy/pytest.ini_tmpl create mode 100644 pyramid/scaffolds/starter/+dot+coveragerc_tmpl create mode 100644 pyramid/scaffolds/starter/pytest.ini_tmpl create mode 100644 pyramid/scaffolds/zodb/+dot+coveragerc_tmpl create mode 100644 pyramid/scaffolds/zodb/pytest.ini_tmpl diff --git a/pyramid/scaffolds/alchemy/+dot+coveragerc_tmpl b/pyramid/scaffolds/alchemy/+dot+coveragerc_tmpl new file mode 100644 index 000000000..273a4a580 --- /dev/null +++ b/pyramid/scaffolds/alchemy/+dot+coveragerc_tmpl @@ -0,0 +1,3 @@ +[run] +source = {{package}} +omit = {{package}}/test* diff --git a/pyramid/scaffolds/alchemy/pytest.ini_tmpl b/pyramid/scaffolds/alchemy/pytest.ini_tmpl new file mode 100644 index 000000000..a30c8bcad --- /dev/null +++ b/pyramid/scaffolds/alchemy/pytest.ini_tmpl @@ -0,0 +1,3 @@ +[pytest] +testpaths = {{package}} +python_files = *.py diff --git a/pyramid/scaffolds/starter/+dot+coveragerc_tmpl b/pyramid/scaffolds/starter/+dot+coveragerc_tmpl new file mode 100644 index 000000000..273a4a580 --- /dev/null +++ b/pyramid/scaffolds/starter/+dot+coveragerc_tmpl @@ -0,0 +1,3 @@ +[run] +source = {{package}} +omit = {{package}}/test* diff --git a/pyramid/scaffolds/starter/pytest.ini_tmpl b/pyramid/scaffolds/starter/pytest.ini_tmpl new file mode 100644 index 000000000..a30c8bcad --- /dev/null +++ b/pyramid/scaffolds/starter/pytest.ini_tmpl @@ -0,0 +1,3 @@ +[pytest] +testpaths = {{package}} +python_files = *.py diff --git a/pyramid/scaffolds/zodb/+dot+coveragerc_tmpl b/pyramid/scaffolds/zodb/+dot+coveragerc_tmpl new file mode 100644 index 000000000..273a4a580 --- /dev/null +++ b/pyramid/scaffolds/zodb/+dot+coveragerc_tmpl @@ -0,0 +1,3 @@ +[run] +source = {{package}} +omit = {{package}}/test* diff --git a/pyramid/scaffolds/zodb/pytest.ini_tmpl b/pyramid/scaffolds/zodb/pytest.ini_tmpl new file mode 100644 index 000000000..a30c8bcad --- /dev/null +++ b/pyramid/scaffolds/zodb/pytest.ini_tmpl @@ -0,0 +1,3 @@ +[pytest] +testpaths = {{package}} +python_files = *.py -- cgit v1.2.3 From 68ba583735aedc6762131af2cf93cf0fdd470fef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20F=C3=A9rotin?= Date: Fri, 6 May 2016 19:45:32 +0200 Subject: doc: Update documentation for using ``py.test [--cov]`` for newly created project with scaffolds. --- docs/narr/project.rst | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/docs/narr/project.rst b/docs/narr/project.rst index 56247ee33..8849e9ee7 100644 --- a/docs/narr/project.rst +++ b/docs/narr/project.rst @@ -209,25 +209,29 @@ On UNIX: .. code-block:: bash - $ $VENV/bin/py.test myproject/tests.py -q + $ $VENV/bin/py.test -q On Windows: .. code-block:: doscon - > %VENV%\Scripts\py.test myproject\tests.py -q + > %VENV%\Scripts\py.test -q Here's sample output from a test run on UNIX: .. code-block:: bash - $ $VENV/bin/py.test myproject/tests.py -q + $ $VENV/bin/py.test -q .. 2 passed in 0.47 seconds The tests themselves are found in the ``tests.py`` module in your ``pcreate`` generated project. Within a project generated by the ``starter`` scaffold, -only two sample tests exist. +only two sample tests exist. Previous command is identical to: + +.. code-block:: bash + + $ $VENV/bin/py.test myproject/tests.py -q .. note:: @@ -235,6 +239,14 @@ only two sample tests exist. to a stream of dots. If you don't pass ``-q``, you'll see verbose test result output (which normally isn't very useful). +Alternatively, if you'd like to see test coverage, pass the ``--cov`` option +to ``py.test``: + +.. code-block:: bash + + $ $VENV/bin/py.test -q --cov + + .. index:: single: running an application single: pserve -- cgit v1.2.3