<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 19 September 2014 09:52, holger krekel <span dir="ltr"><<a href="mailto:holger@merlinux.eu" target="_blank">holger@merlinux.eu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi Andreas, all,<br>
<span class=""><br>
On Fri, Sep 19, 2014 at 09:06 +0200, Andreas Pelme wrote:<br>
> Hi,<br>
><br>
> First: Thanks for the fixes and release, my test suite runs fine with the new version!<br>
><br>
> On 18 sep 2014, at 20:56, holger krekel <<a href="mailto:holger@merlinux.eu">holger@merlinux.eu</a>> wrote:<br>
> > On Thu, Sep 18, 2014 at 20:51 +0200, Anatoly Bubenkov wrote:<br>
> >> hmm, but that grouping is not important for session scoped fixtures, right?<br>
> >> i mean, what's the sense of tearing down the session-scoped fixture, even<br>
> >> if most likely it will be not used by any test, earlier than the end of the<br>
> >> session?<br>
> ><br>
> > Parametrized session-scoped fixtures, for example, may depend on being torn<br>
> > down, not all be active at the same time.  In any case, it's part of a<br>
> > general scheme to teardown fixtures as early as possible, not as late as<br>
> > possible.  We can discuss/play with that and introduce an option which<br>
> > prohibits it, possibly.<br>
><br>
><br>
> I’d like an option/hint (in a sense similar to pytest.mark.trylast) to tell pytest to tear down fixtures as late as possible. Or a higher level scope than session, that is cached until the end of the entire test run.<br>
<br>
</span>Interesting idea.  Maybe we could add something to the fixture decorator, e.g.:<br>
<br>
    @pytest.fixture(scope="session", lateteardown=True)<br></blockquote><div>how about:</div><div>@pytest.fixture(scope="<scope>", teardown='<(early or demand (default)) | (session or late, not sure)>')</div><div><br></div><div>the teardown 'session' will clearly tell the user when this fixture will be teared down</div><div>'late' also works, but not so clear</div><div><br></div><div>teardown 'demand' clearly tells that it's teardown will depend on the demand of the fixture from the tests</div><div>'early' - same as with 'late'</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<span class=""><br>
> I’ve was not aware of this situation until I hit issue 503, and have always assumed that session fixtures cannot be teared down more than once.<br>
><br>
> pytest-django’s internal fixtures and other fixtures I’ve written depends on having a single invocation for session fixtures. The teardown bugs in these fixtures can (and should) of course be fixed to work properly multiple times.<br>
><br>
> Even if these fixtures were correct, from a performance point of view, tearing down some of these fixtures is a big issue, since session fixtures are typically very slow in the first place.<br>
<br>
</span>I'd like to see if with pytest-xdist-1.11 there still is a problem.<br>
Let's try to make everything work by default without adding new options.<br>
We might just allow non-parametrized session fixtures to survive<br>
until the end of a session (or rather a process: i now think that<br>
"session" should have been named "process" because it better avoids<br>
misconceptions when things run distributed).  A "non parametrized<br>
session fixture" means that it is itself not parametrized and none of<br>
its fixture dependencies is, neither (recursive definition).  We should<br>
be able to determine this property at collection time and thus postpone<br>
teardown accordingly.<br></blockquote><div>session is rather good name, because if it will be the process, a lot of questions will arise why pytest has session everywhere internally :)</div><div>also sometimes it's probably needed to start multiple sessions, who knows?</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
I presume that with module and class scope people don't presume that<br>
a fixture survives until the end of a process so eager teardown is less<br>
of a problem, there, right?<br>
<br></blockquote><div>agree</div><div><br></div></div><div><br></div>-- <br><div dir="ltr">Anatoly Bubenkov<br></div>
</div></div>