-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use of 'pytest' in setup.cfg collides with 'pytest' distutils command #567
Comments
Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42): The reason why pytest looks in setup.cfg (as does tox) is that i'd eventually like to have all project specific metadata in a setup.cfg. I don't know how much people use a "[pytest]" section in setup.cfg these days, however. And i don't know how much of a worthwhile goal it is. Dropping support for [pytest] could only happen for the second next major release (it would be deprecated in 2.7). So i guess option "2" is the best one for you for now, indeed. |
Original comment by Jason R. Coombs (BitBucket: jaraco, GitHub: jaraco): I happen to use the "[pytest]" section in setup.cfg extensively, but that's just one use case. It seemed like the most canonical place to add recommended options for a project's pytest runs. Indeed, it sounds as if that would have been your recommendation as well. If the project chooses to deprecate that, it could continue to support options in the setup.cfg, but under a different section (perhaps something with spaces that would be unlikely to collide with a command). Or pytest could prefer use of one of the other files instead. I'll explore the use of suppressing unknown options to the command (option 2). I don't know how straightforward that will be, because distutils uses its own port of getopt with which I'm not familiar. It's something I need to learn, though, to solve other setuptools issues. |
Original comment by Jason R. Coombs (BitBucket: jaraco, GitHub: jaraco): I looked into the code for pytest-runner and pytest, but it looks like it'll be impossible to adequately bypass this issue in pytest-runner. First, when pytest loads settings from the .ini file, it loads the settings into a variable and references the keys throughout the code, so there's no authoritative list of options that might be expected to exist. That is, there's no way pytest-runner could introspect pytest to determine which options to whitelist, so any white list would need to be updated manually and periodically, and the list of options could be found anywhere in pytest. Second, I looked into whitelisting any unrecognized option, but that's not possible either because pytest-runner is a distutils command, and commands are parsed in distutils.dist.Distribution, part of the stdlib. I considered adding a
That doesn't work, though, because command options are not the only aspect that calls and depends on Third, I considered just trapping the error message, but as far as I can tell, there's no way to do that from the API exposed by distutils. So I'm left feeling that options (2) and (3) aren't really viable without a refactoring of distutils, which is its own quagmire. And indeed, those options would only serve as a workaround and wouldn't resolve the essential conflict.
I see this goal in direct conflict with a 'pytest' command. Could pytest (the project) consider using a different section in setup.cfg to avoid the collision? If pytest wants to own the [pytest] section in setup.cfg, then pytest-runner should use another name for its distutils command. Assuming the current state of the art for distutils and setuptools, I don't see any other options. |
Original comment by Ronny Pfannschmidt (BitBucket: RonnyPfannschmidt, GitHub: RonnyPfannschmidt): i wonder if renaming the section to |
We should deprecate and drop usage in setup.cfg |
Related to #1311 |
As discussed here pytest-dev/pytest-runner#7 and sort of pytest-dev/pytest#567
Make pytest the default test runner and remove support for nose. Tests can be run using: - py.test - python setup.py test The pytest configuration needs to move from setup.cfg to pytest.ini to support this - see pytest-dev/pytest#567 and https://bitbucket.org/pytest-dev/pytest-runner/issues/7/support-all-pytest-commands .
All said up to this point in this thread, I probably would have voted for option 1: don't use If there are other problems, though (#1311), then I still like @RonnyPfannschmidt's suggestion of changing to a prefix like If this is deemed an abuse of distutils' turf, I can see the argument to remove @foxx's problem report in #1311 is a little unclear to me: it appears he was using |
FWIW, Coverage is another that supports |
@ches thanks for the reference, but as you can see, the "sane" tools do use a prefix while pytest does not |
My opinion remains basically the same, though it's crystallized even more now. The namespace for non-prefixed names in setup.cfg is practically if not explicitly reserved for Distutils command names, so pytest should drop support for it or use a prefixed name. I would be happy to switch pytest-runner back to using the 'ptr' name (it's currently still supported), but only if there's a consensus to do so, and I still feel like that's a less suitable solution than the alternative. |
Hi guys! I ended up to this page shortly after trying to implement the good practices from http://docs.pytest.org/en/latest/goodpractices.html What should I do to pass over this issue? ...and be able to run tests using the standard I am using pytest and partially tox (tox when doing matrix builds locally and just pytest when on travis as it has its own matrix setup). Thanks. |
@ssbarnea You should be fine following the advice of the documentation to use pytest-runner, just note that you can't use a |
This one seems like an easy, backwards-incompatible change for 3.0 - change |
@The-Compiler And introduce forward-compatibilty for |
@jaraco Yeah - we want to release 3.0 ASAP, I was looking at which issues really should go into 3.0 (because otherwise they'd need to be postponed to 4.0). |
Anyone capacities to pick this one up? |
@hackebrot I have to remove invocation fixtures first and was going to get this if nobody volunteers until then, but if you have the time and want to tackle this it would be great. Just to make sure I understand, the plan is to add support for Is my understanding correct? |
I am busy with #1795 atm, but I'd like to see this being worked on. 😄 Can't wait to use pytest 3.0. 🚀 |
Also deprecate [pytest] usage in setup.cfg files Fix pytest-dev#567
Originally reported by: Jason R. Coombs (BitBucket: jaraco, GitHub: jaraco)
In pytest-runner 2, I adapted pytest-runner to support the 'pytest' distutils command. However, because the pytest project itself uses the
[pytest]
section of setup.cfg, that conflicts with the same section for the 'pytest' distutils command.Using the 'pytest' distutils command in a project which specifies, for example, 'norecursedirs', the runner will fail because the pytest-runner distutils command doesn't recognize that parameter (or any other ini options). An example error message is:
I see a few options here:
I suspect there are other options, too. I'm not particularly happy with any of those options, but I'm leaning toward (2).
I've filed the ticket here with pytest for two reasons:
@hpk42 What is your reaction? What would you suggest?
The text was updated successfully, but these errors were encountered: