Skip to content
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

pytest.mark usefixture vs usefixtures #3972

Closed
digitalresistor opened this issue Sep 12, 2018 · 4 comments
Closed

pytest.mark usefixture vs usefixtures #3972

digitalresistor opened this issue Sep 12, 2018 · 4 comments
Labels
topic: fixtures anything involving fixtures directly or indirectly topic: marks related to marks, either the general marks or builtin type: question general question, might be closed after 2 weeks of inactivity

Comments

@digitalresistor
Copy link

I know that this is something that bites me every so often, and it recently bit a colleague of mine, however when using fixtures and marking a class/function as require a fixture, it is very unintuitive to use usefixtures when you intend to use only a single fixture.

Would it be possible to register usefixture as an alias for usefixtures to avoid this confusion and a lot of head scratching?

Especially because pytest does not seem to error when you use a non-existent mark.

@Zac-HD Zac-HD added type: question general question, might be closed after 2 weeks of inactivity topic: fixtures anything involving fixtures directly or indirectly topic: marks related to marks, either the general marks or builtin labels Oct 19, 2018
@Zac-HD
Copy link
Member

Zac-HD commented Dec 9, 2018

Especially because pytest does not seem to error when you use a non-existent mark.

As discussed on #4506, we're more likely to make it an error to use an undefined mark. From a perspective of "there should be one-- and preferably only one --obvious way to do it.", that's arguably better than an alias anyway!

@Zac-HD Zac-HD closed this as completed Dec 9, 2018
@digitalresistor
Copy link
Author

@Zac-HD I would be perfectly happy with that solution too :-)

@nicoddemus
Copy link
Member

@bertjwregeer you can make pytest error out on unknown marks by passing --strict. You might decide to add this to your pytest.ini as well so you enforce it across the project:

[pytest]
addopts = --strict

@digitalresistor
Copy link
Author

@nicoddemus I had not found that while searching, but I will definitely add that to our pytest.ini files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: fixtures anything involving fixtures directly or indirectly topic: marks related to marks, either the general marks or builtin type: question general question, might be closed after 2 weeks of inactivity
Projects
None yet
Development

No branches or pull requests

3 participants