[TIP] pytest, setup.py and custom options
sean at seanfisk.com
Tue Nov 26 21:12:11 PST 2013
The excellent pytest documentation has a section on Setuptools
In that example, you would want to write instead:
self.test_args = ['--flakes']# ...
These arguments get passed to pytest.main(), which is the key to running
pytest through Python.
The one thing I never loved about these plugins (along with the pytest PEP8
plugin) is that they only check files that are discovered. If you want to
check your code as well as your test files, you have to run pytest *on your
source tree too*. That never felt right to me. In addition, I had generated
Python files that I didn’t want to syntax check. My solution was to run
flake8 on all files reported as
my version control system. *[Disclaimer:
self-promotion]* This is integrated into my Python Project
It uses Paver instead of Setuptools for calling pytest, so it might be too
heavyweight for your needs.
Either way, I hope this helps!
On Tue, Nov 26, 2013 at 8:57 PM, Daniel Farina <daniel at heroku.com> wrote:
> I would like to support "python setup.py test" to allow people to more
> easily get started with a project I work on. I use pytest, which
> supports a large collection of options, and my scrying on the Internet
> fails to produce a way to support simply passing these through to
> pytest to interpret.
> For example, let's say I normally I run something like this:
> py.test --flakes
> This works fine.
> But suppose I try to enable precisely this same thing via "python
> setup.py test --flakes", then I receive:
> "error: option --flakes not recognized"
> It's not entirely clear to me when these option checks occur and how I
> could accept all options and delegate their handling (and error
> messages) to pytest.
> Thanks in advance for any advice one can offer.
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the testing-in-python