test_ok2/src
Ran Benita bb878a2b13 runner: don't try to teardown previous items from pytest_runtest_setup
While working on improving the documentation of the
`pytest_runtest_setup` hook, I came up with this text:

> Called to perform the setup phase of the test item.
>
> The default implementation runs ``setup()`` on item and all of its
> parents (which haven't been setup yet). This includes obtaining the
> values of fixtures required by the item (which haven't been obtained
> yet).

But upon closer inspection I noticed this line at the start of
`SetupState.prepare` (which is what does the actual work for
`pytest_runtest_setup`):

    self._teardown_towards(needed_collectors)

which implies that the setup phase of one item might trigger teardowns
of *previous* items. This complicates the simple explanation. It also
seems like a completely undesirable thing to do, because it breaks
isolation between tests -- e.g. a failed teardown of one item shouldn't
cause the failure of some other items just because it happens to run
after it.

So the first thing I tried was to remove that line and see if anything
breaks -- nothing did. At least pytest's own test suite runs fine. So
maybe it's just dead code?
2020-06-14 13:48:05 +03:00
..
_pytest runner: don't try to teardown previous items from pytest_runtest_setup 2020-06-14 13:48:05 +03:00
pytest Handle EPIPE/BrokenPipeError in pytest's CLI 2020-05-08 12:51:02 +03:00