Re: [pytest-dev] Fixture ordering and scopes

2018-03-20 Thread Bruno Oliveira
Howdy! On Thu, Mar 15, 2018 at 6:42 PM Bruno Oliveira wrote: > I opened up a PR which > does sort parameters by scope while keeping the relative order of fixtures > of same scope intact, and the test suite passes without failures so if the > curre

Re: [pytest-dev] Fixture ordering and scopes

2018-03-20 Thread Bruno Oliveira
On Tue, Mar 20, 2018 at 10:45 AM Floris Bruynooghe wrote: > On Tue, Mar 20 2018, Bruno Oliveira wrote: > > > > @pytest.fixture(scope='session', autouse=True) > > def my_setup_logging(log_setup): pass > > > > @pytest.fixture(scope='session', autouse=True) > > def my_db_setup(my_setup_logging, db_s

Re: [pytest-dev] Fixture ordering and scopes

2018-03-20 Thread Floris Bruynooghe
On Tue, Mar 20 2018, Bruno Oliveira wrote: > On Sat, Mar 17, 2018 at 6:38 PM Floris Bruynooghe wrote: > >> >> I'm still not following this, I'm probably being silly. You have 4 >> autouse session-scoped fixtures but with a dependecy chain as >> my_db_setup -> my_setup_logging -> setup_logging an

Re: [pytest-dev] Fixture ordering and scopes

2018-03-20 Thread Bruno Oliveira
On Sat, Mar 17, 2018 at 6:38 PM Floris Bruynooghe wrote: > > I'm still not following this, I'm probably being silly. You have 4 > autouse session-scoped fixtures but with a dependecy chain as > my_db_setup -> my_setup_logging -> setup_logging and then an unrelated > db_setup. What am I missing

Re: [pytest-dev] Fixture ordering and scopes

2018-03-17 Thread Floris Bruynooghe
Bruno Oliveira writes: > On Fri, Mar 16, 2018 at 2:36 PM Floris Bruynooghe wrote: > >> Bruno Oliveira writes: >> >> > So the order is important here, and leaving it undefined will require >> > people to write this instead: >> > >> > @pytest.fixture(scope='session', autouse=True) >> > def my_set

Re: [pytest-dev] Fixture ordering and scopes

2018-03-16 Thread Bruno Oliveira
On Fri, Mar 16, 2018 at 2:36 PM Floris Bruynooghe wrote: > Bruno Oliveira writes: > > > So the order is important here, and leaving it undefined will require > > people to write this instead: > > > > @pytest.fixture(scope='session', autouse=True) > > def my_setup_logging(log_setup): pass > > > >

Re: [pytest-dev] Fixture ordering and scopes

2018-03-16 Thread Floris Bruynooghe
Bruno Oliveira writes: > > On Fri, Mar 16, 2018 at 5:42 AM Floris Bruynooghe wrote: > >> Bruno Oliveira writes: >> > For example suppose you have two session scoped fixtures from different > libraries which don't know about each other: > > * `log_setup` from `core_logging` setups the builtin log

Re: [pytest-dev] Fixture ordering and scopes

2018-03-16 Thread Isaul Vargas
Another reason in support of a well defined order is because some library authors will create function scoped fixtures that depend on the objects in a session scoped fixture. If those tests do run out of order, tests will break. On Fri, Mar 16, 2018 at 8:18 AM, Vasily Kuznetsov wrote: > Hi Brun

Re: [pytest-dev] Fixture ordering and scopes

2018-03-16 Thread Vasily Kuznetsov
Hi Bruno, Your example is a good argument, I haven't considered third party fixtures over which the developer of the test suite has less control. I agree that requiring users to jumps through extra hoops to give third-party fixtures the desired order is too high of a price to pay for the nudge tow

Re: [pytest-dev] Fixture ordering and scopes

2018-03-16 Thread Bruno Oliveira
Hi Vasily! On Fri, Mar 16, 2018 at 7:17 AM Vasily Kuznetsov wrote: > I very much agree with Floris that if you need fixture A to run before > fixture B and otherwise things break, this is called "dependency" and it's > better if it's explicitly declared. > Definitely, if a fixture requires some

Re: [pytest-dev] Fixture ordering and scopes

2018-03-16 Thread Bruno Oliveira
Hi Floris, On Fri, Mar 16, 2018 at 5:42 AM Floris Bruynooghe wrote: > Bruno Oliveira writes: > > > Hi everyone and Holger, > > > > Looking at the code below: > > > > > > data = {} > > @pytest.fixture(scope='session')def clean_data(): > > data.clear() > > @pytest.fixture(autouse=True)def ad

Re: [pytest-dev] Fixture ordering and scopes

2018-03-16 Thread Vasily Kuznetsov
I very much agree with Floris that if you need fixture A to run before fixture B and otherwise things break, this is called "dependency" and it's better if it's explicitly declared. I can't easily imagine a situation where declaring dependencies would be too much work or not desirable for some othe

Re: [pytest-dev] Fixture ordering and scopes

2018-03-16 Thread Floris Bruynooghe
Brian Okken writes: > I get numerous questions about it, and I always tell people to create > artificial dependencies between fixtures that need to run in a certain > order. I'm not sure I follow why you consider them to be *artificial* dependencies. If a function-scoped fixture depends on anyth

Re: [pytest-dev] Fixture ordering and scopes

2018-03-16 Thread Floris Bruynooghe
Bruno Oliveira writes: > Hi everyone and Holger, > > Looking at the code below: > > > data = {} > @pytest.fixture(scope='session')def clean_data(): > data.clear() > @pytest.fixture(autouse=True)def add_data(): > data['value'] = 1 > @pytest.mark.usefixtures('clean_data')def test_foo(): >

Re: [pytest-dev] Fixture ordering and scopes

2018-03-15 Thread Isaul Vargas
I too have observed this weird ordering. I would like like the order of fixtures to always respect the order of scopes. On Thu, Mar 15, 2018 at 6:47 PM, Brian Okken wrote: > Bruno, > > Please, merge that PR! > caveat: I have not reviewed the code. > > However, ... > I get numerous questions abou

Re: [pytest-dev] Fixture ordering and scopes

2018-03-15 Thread Brian Okken
Bruno, Please, merge that PR! caveat: I have not reviewed the code. However, ... I get numerous questions about it, and I always tell people to create artificial dependencies between fixtures that need to run in a certain order. The general mental model that people have for fixtures is that they

[pytest-dev] Fixture ordering and scopes

2018-03-15 Thread Bruno Oliveira
Hi everyone and Holger, Looking at the code below: data = {} @pytest.fixture(scope='session')def clean_data(): data.clear() @pytest.fixture(autouse=True)def add_data(): data['value'] = 1 @pytest.mark.usefixtures('clean_data')def test_foo(): assert data.get('value') Should test_foo f