I've seen issues with the mock library where patching the same thing multiple times can cause the patchedness to leak out of a test - because the teardown order isn't guaranteed the way it was being used. So if multiple monkeypatches are going to be created at the same scope, the teardown order had better be reverse of construction, or you're going to risk leaking the outer monkeypatch.
-- lahwran On Fri, Oct 11, 2013 at 8:12 AM, holger krekel <[email protected]> wrote: > On Fri, Oct 11, 2013 at 10:51 -0300, Bruno Oliveira wrote: > > On Fri, Oct 11, 2013 at 8:35 AM, holger krekel <[email protected]> > wrote: > > > > > On Fri, Oct 11, 2013 at 08:25 -0300, Bruno Oliveira wrote: > > > > On Fri, Oct 11, 2013 at 8:14 AM, Vladimir Keleshev < > > > [email protected]>wrote: > > > > > > > > > > If you refer to tmpdir/monkeypatch and potentially others, i > agree > > > > > > that the current behaviour is more surprising (sharing the tmpdir > > > > > > across multiple fixtures which don't even neccessarily know about > > > each > > > > > > other). > > > > > > > > > > Absolutely. Was a major WAT for me. > > > > > > > > > > > > > Weird, to me it was the exact opposite about tmpdir: it is a common > usage > > > > in our code base to create a temporary directory for usage through a > test > > > > suite (usually a module containing related tests). And different > fixtures > > > > sharing tmpdir makes sense in this scenario. > > > > > > Are you really talking about the pytest fixture "tmpdir" here? > > > "Throughout the test suite" sounds like something else because > > > "tmpdir" is function scoped and created afresh for each test function > > > requesting it. > > > > > > > Sorry I wasn't very clear, I meant using the same fixture instance for > each > > test, like two fixtures that depend on tmpdir (independently) and both > > fixtures are used in a test function that also needs a tmpdir; in this > case > > the test method and fixtures all share the same tmpdir instance. > > Ok, and your setup expects to get the same tmpdir then, IIUC. I might > even have a similar situtation myself in some projects. So i guess we > will need to introduce a new name for the "each" scoped temporary dir. > That is a minor issue (except that naming is hard, of course) compared > to the actual implementation of the "each" scope. > > cheers, > holger > > > But now I misunderstood the original issue, my apologies, now I see what > > was really meant. > > > > Cheers, > > Bruno. > _______________________________________________ > Pytest-dev mailing list > [email protected] > https://mail.python.org/mailman/listinfo/pytest-dev >
_______________________________________________ Pytest-dev mailing list [email protected] https://mail.python.org/mailman/listinfo/pytest-dev
