In this case, py.test was totally new to me. I had always used
``nose`` or ``tox`` that someone else wrote or setup.py'ed for
me. I was a beginner to py.test and test discoverability.
When I tried running tests out of the box following that pattern
via ``py.test``, it didn't work. Hmm, I thought, there *must*
be some way to make it work. So I Google Fu'd, visited the
link[1] to read about test discovery, and it became clear in my
mind how to do so. I then wrote the documentation for how to
run tests for the scaffold. As a beginner, I managed to work it out.
Because I learned something from this process, I think it is
good for beginners to realize that there is more to py.test than
its mere invocation without options. There's a lot to explore.
After having this discussion, I think I should add this
reference to the tutorial installation step.
For what it's worth, when we go deeper into tests, we use the
simple invocation with a single option to suppress output,
``py.test -q``.[2]
[1] http://pytest.org/latest/goodpractices.html#python-test-discovery
[2]
http://docs.pylonsproject.org/projects/pyramid/en/1.7-branch/tutorials/wiki2/tests.html#running-the-tests
--steve
On 5/6/16 at 2:51 PM, vincent.fero...@gmail.com (Vincent
Férotin) pronounced:
Thank you, Michael and Steve, for the quick responses.
I will open a PR on github with changes to take in consideration what you said.
@Steve:
Sure you can explicitly tell py.test to run a specific test module,
but the whole point of my suggestion is to not pass test module path
to py.test. It's the point of view of a beginner, not familiar with
Pyramid scaffolds nor py.test: isn't it easier/more convenient to only
run ``py.test`` at project's root directory, just after project
creation by scaffold, and get all tests collected by default?
-- Vincent
2016-05-05 19:46 GMT+02:00 Steve Piercy <steve.piercy....@gmail.com>:
On 5/5/16 at 9:44 AM, vincent.fero...@gmail.com (Vincent Férotin)
pronounced:
scaffolds are not ready for naive usage of py.test by new comers to
Pyramid,
i.e. running ``py.test [--cov]`` at new project's root collects no tests.
You are correct in that one cannot just naïvely run:
$ py.test [--cov]
py.test discovers tests in the following manner:
http://pytest.org/latest/goodpractices.html#python-test-discovery
By following the instructions for the SQLAlchemy + URL dispatch wiki
tutorial to get started:
http://docs.pylonsproject.org/projects/pyramid/en/1.7-branch/tutorials/wiki2/
installation.html
I can run the tests:
stevepi-mbp:tutorial stevepiercy$ $VENV/bin/py.test tutorial/tests.py -q
..
2 passed in 0.54 seconds
stevepi-mbp:tutorial stevepiercy$ $VENV/bin/py.test --cov=tutorial
--cov-report=term-missing tutorial/tests.py
======================================================================= test
session starts
========================================================================
platform darwin -- Python 3.5.0, pytest-2.9.1, py-1.4.31, pluggy-0.3.1
rootdir: /Users/stevepiercy/pyramidtut/tutorial, inifile:
plugins: cov-2.2.1
collected 2 items
tutorial/tests.py ..
--------------------------------------------------------- coverage: platform
darwin, python 3.5.0-final-0
----------------------------------------------------------
Name Stmts Miss Cover Missing
----------------------------------------------------------------
tutorial/__init__.py 8 6 25% 7-12
tutorial/models/__init__.py 22 0 100%
tutorial/models/meta.py 5 0 100%
tutorial/models/mymodel.py 8 0 100%
tutorial/routes.py 3 3 0% 1-3
tutorial/scripts/__init__.py 0 0 100%
tutorial/scripts/initializedb.py 26 26 0% 1-45
tutorial/tests.py 39 0 100%
tutorial/views/__init__.py 0 0 100%
tutorial/views/default.py 12 0 100%
tutorial/views/notfound.py 4 4 0% 1-7
----------------------------------------------------------------
TOTAL 127 39 69%
===================================================================== 2
passed in 0.57 seconds
=====================================================================
stevepi-mbp:tutorial stevepiercy$
--steve
------------------------
Steve Piercy, Soquel, CA
--
You received this message because you are subscribed to the Google Groups
"pylons-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to pylons-devel+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/pylons-devel.
For more options, visit https://groups.google.com/d/optout.
------------------------
Steve Piercy, Soquel, CA
--
You received this message because you are subscribed to the Google Groups
"pylons-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to pylons-devel+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/pylons-devel.
For more options, visit https://groups.google.com/d/optout.