`pytest_unconfigure` can be called even if `pytest_configure` was not.
In order to avoid errors during unconfigure only perform the unconfigure
if the configure was performed. Add a counter which is incremented
before configure to track the number of times pytest started
initialization so that the config is not popped early from the stack.
The pytest rootdir is the directory containing pytest.ini (or similar):
https://docs.pytest.org/en/latest/reference/customize.html#rootdir
This allows you to run pytest when the current working directory isn't
the same as the directory containing the tests. I need to do that
because in my system, the directory containing the tests is on a
read-only filesystem.
`testdir` is deprecated. It's identical to `pytester`, except that
`testdir` returns `py.path` objects whereas `pytester` returns Python
stdlib `Path` objects. So I had to update usages of those paths.
`pytester` was added in pytest 6.2, which is our minimum supported
version.
Pytest 7.2.0 dropped its dependency on the `py` package. We don't
specify `py` explicitly as a dependency, so tests starting failing since
the release of pytest 7.2.0.
To drop this dependency, pytest vendored `py.io.TerminalWriter` into
`_pytest._io` in pytest commit 276405a03 (6.0.0rc1). It looks like we
still support pytest 5.0 —at least it's listed in tox.ini— so I fall
back to importing from `py.io` if it isn't present in `_pytest`.
This was our only direct use of the `py` library.