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

mark fixtures #2872

Closed
gaborbernat opened this issue Oct 26, 2017 · 17 comments
Closed

mark fixtures #2872

gaborbernat opened this issue Oct 26, 2017 · 17 comments
Labels
topic: fixtures anything involving fixtures directly or indirectly topic: marks related to marks, either the general marks or builtin type: enhancement new feature or API change, should be merged into features branch

Comments

@gaborbernat
Copy link
Contributor

Is it possible to mark a fixture? E.g. if I have a slow fixture, can I mark the fixture as slow, which then would propagate to mark all tests using that fixture as slow. How hard is to achieve this? Thanks!

@RonnyPfannschmidt
Copy link
Member

this is currently not implemented and currently impossible to correctly implement due to massive issues in the mark system

@gaborbernat
Copy link
Contributor Author

then is there a mark system refactor in plan? 👍

@RonnyPfannschmidt
Copy link
Member

yes - there was a ml thread, an the next step is killing old style marker transfer in favour of nodes owning their marks

however this still doesnt solve the fixture case as we would need to collect the complete fixture dependency/override graph and all marks within it in order to pass the data along

in addition markers like parametrize would be a pain if they where passed around that way

on top of that fixture params expansion may bring in marks that are passed in already

@gaborbernat
Copy link
Contributor Author

is there a place we can follow the progress of this beside the mailing list?

@RonnyPfannschmidt
Copy link
Member

there is a project about sorting the mark issues out here in the issue tracker

@nicoddemus nicoddemus added topic: fixtures anything involving fixtures directly or indirectly topic: marks related to marks, either the general marks or builtin type: enhancement new feature or API change, should be merged into features branch labels Oct 26, 2017
@gaborbernat
Copy link
Contributor Author

@RonnyPfannschmidt @nicoddemus we the revamp of the fixtures is now possible to achieve this?

@Zac-HD
Copy link
Member

Zac-HD commented Oct 21, 2018

Per #3664, we have decided not to support marks on fixtures, and make this into an explicit error.

@Zac-HD Zac-HD closed this as completed Oct 21, 2018
@gaborbernat
Copy link
Contributor Author

I don't see any explanation why this is the case 🤔 is this a bad practice?

@RonnyPfannschmidt
Copy link
Member

IIts simply an utter hell when matching various use-cases, not doing something incredible hhard and error prone is vital for the sustenance of a volunteer driven project

@gaborbernat
Copy link
Contributor Author

I guess here lies my limitation, don't know how hard it is. In my mind is just interating over all tests and all which have a fixture get a mark. This could be a final phase at the end of test collection.

@RonnyPfannschmidt
Copy link
Member

Its technically impossible to do it correctly withe the current structure oof the fixture system

@nicoddemus
Copy link
Member

Just to add to @RonnyPfannschmidt's response: after collection, pytest doesn't have a map of which fixtures are used by which tests, fixtures are created lazily during test setup or even inside tests themselves using request.getfixturevalue.

@blueyed
Copy link
Contributor

blueyed commented Nov 9, 2019

What do you think of a --mark-fixture option that would add a mark to all tests using a fixture?
blueyed#98

This allows for applying marks to tests using specific fixtures, and then
allows to (de)select them via -m, e.g. --mark-fixture foo:bar -m "not bar".

That way you basically get the originally requested feature (what I understood from skimming), but it is more dynamic in general.

@RonnyPfannschmidt
Copy link
Member

as proposed, i'm strictly opposed

@blueyed
Copy link
Contributor

blueyed commented Nov 9, 2019

@RonnyPfannschmidt

as proposed, i'm strictly opposed

Care to elaborate?
It basically allows to have the commonly used boilerplate with custom --run-foo options, e.g. like you've posted in #5706 (comment).

@RonnyPfannschmidt
Copy link
Member

its the wrong place to put it(cli options) , the implementation is wrong as it auto-adds "wrong" / missing marks , furthermore its limited by name, which is limited for setups where a reshaped fixture is in use in sub-tress for example

basically its defined at the wrong place, sets details wrong and is impossible to extend

@blueyed
Copy link
Contributor

blueyed commented Nov 10, 2019

Thanks for the explanation.

its the wrong place to put it(cli options)

Why?

the implementation is wrong as it auto-adds "wrong" / missing marks

That's the point: auto-adding marks.

furthermore its limited by name, which is limited for setups where a reshaped fixture is in use in sub-tress for example

It's not meant for complex setups.

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: enhancement new feature or API change, should be merged into features branch
Projects
None yet
Development

No branches or pull requests

5 participants