Skip to content
This repository has been archived by the owner on Dec 4, 2023. It is now read-only.

Support all [pytest] commands #7

Closed
jaraco opened this issue Aug 27, 2015 · 5 comments
Closed

Support all [pytest] commands #7

jaraco opened this issue Aug 27, 2015 · 5 comments

Comments

@jaraco
Copy link
Contributor

jaraco commented Aug 27, 2015

Originally reported by: Florian Wilhelm (Bitbucket: florianwilhelm, GitHub: florianwilhelm)


When defining user options like norecursedirs in setup.cfg or pytest.ini like explained here, pytest-runner can't handle them.


@jaraco
Copy link
Contributor Author

jaraco commented Aug 27, 2015

Original comment by Jason R. Coombs (Bitbucket: jaraco, GitHub: jaraco):


I don't understand. I use norecursedirs in pytest.ini all the time, and I use pytest-runner almost exclusively. What is it you're expecting to happen that's not happening?

@jaraco
Copy link
Contributor Author

jaraco commented Aug 27, 2015

Original comment by Florian Wilhelm (Bitbucket: florianwilhelm, GitHub: florianwilhelm):


py.test reads its configuration from pytest.ini and setup.cfg. If I have an section [pytest] in setup.cfg where I add norecursedirs, py.test will interpret it and at the same time setuptools will pass it as user-defined option to your PyTest class which knows nothing about this option.

This actually also causes another problem if a I use only setup.cfg to configure py.test. Since your runner registers the command class pytest everything I add as option addopts in [pytest] will be passed to your runner and py.test. I would like to configure that python setup.py test runs with a lot of predefined options like tests --cov my_project --cov-report term-missing --verbose but when I run py.test manually from the command line I don't want it to add any options to it. You could circumvent this by choosing a different name than pytest as command class.

@jaraco
Copy link
Contributor Author

jaraco commented Aug 27, 2015

Original comment by Florian Wilhelm (Bitbucket: florianwilhelm, GitHub: florianwilhelm):


Actually unrelated but I still want to ask. Why do you use this _save_argv context manager to parse options to py.test. Couldn't you just use this instead:

#!python

    def run_tests(self):
        import pytest
        errno = pytest.main(self.addopts)
        sys.exit(errno)

@jaraco
Copy link
Contributor Author

jaraco commented Aug 27, 2015

Original comment by Jason R. Coombs (Bitbucket: jaraco, GitHub: jaraco):


Florian, the issue with setup.cfg lies with pytest itself and is reported here. The workaround is to use pytest.ini instead of setup.cfg for options to the pytest run, but use setup.cfg for standard parameters to the pytest distutils command. Furthermore, you may add the alias of test = pytest in setup.cfg such that setup.py test invokes pytest. See the pmxbot project for an example that does what you're seeking.

Why do you use this _save_argv

I suspect it's because pytest.main didn't accept command line parameters at the time pytest-runner was originally authored. Or it's possible I tried that technique and ran into problems, but if so, there's no record of that in the commit history. If you can determine when that support was added to pytest and test your technique, I'd be happy to accept it. I'm all for shorter, simpler code.

@jaraco
Copy link
Contributor Author

jaraco commented Aug 27, 2015

Original comment by Florian Wilhelm (Bitbucket: florianwilhelm, GitHub: florianwilhelm):


Jason, thanks for your reply. I prefer having only one config file, namely setup.cfg, so until this issue is resolved I'll use my own modified version of pytest-runner.

@jaraco jaraco closed this as completed Feb 13, 2016
jbarlow83 pushed a commit to ocrmypdf/OCRmyPDF that referenced this issue Feb 16, 2016
jaraco added a commit that referenced this issue Feb 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant