[TIP] How to parameterize a fixture based on a parser option with py.test?
lodagro at gmail.com
Fri Dec 13 06:51:09 PST 2013
2013/12/13 holger krekel <holger at merlinux.eu>
> On Fri, Dec 13, 2013 at 15:06 +0100, Wouter Overmeire wrote:
> > Somehow i missed the point that it is possible to access the config
> > trough the metafunc argument of pytest_generate_tests when i first looked
> > at the docs. Based on your recommendations i gave it another go, problem
> > solved. Thanks for your feedback!
> > There is however another problem now. There is a big difference in the
> > order of configuration / test execution when deferring the setup of
> > parametrized resources.
> > When using the params argument of the pytest.fixture decorator the tests
> > are run such that for a given config of the platform, all tests run after
> > each other. This is what i want, since the config is time-consuming
> > compared to running the tests. When using the pytest_generate_tests
> > function to parameterize the platform fixture, the tests are run, such
> > one give tests is executed for all configs, than the next test for all
> > selcted configs, and so on. Is there an easy way to change the ordering?
> > should i implement my own ordering, maybe using
> > pytest_collection_modifyitems?
> If configs are a per-session thing (it sounds so), you should additionally
> pass "scope='session'" to metafunc.parametrize(), which should effect
> the ordering you ask for. Other caching scope values are 'module' or
> but most often people use 'session' and 'function' (the default).
> Does that solve it?
Yes it does.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the testing-in-python