Do not try to initialize async fixtures without explicit asyncio mark in strict mode #307
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes a bug that breaks compatibility with pytest_trio (see #298).
The PR:
Adds pytest-trio to the test dependencies.
Removes test with obsolete "forbid_global_loop".
forbid_global_loop was an option to
pytest.mark.asyncio
which was removed in v0.6.0. The two subprocess tests are otherwise identical. Therefore, one of the tests was removed along with the obsolete option.Fixes a bug that causes a package-scoped event_loop fixture to leak into other tests.
The expected behaviour is that the
event_loop
fixture defined intests/sessionloop/conftest.py
is torn down when all tests intests/sessionloop
are complete. Running the tests with the pytest option--setup-show
pointed out that the fixture is torn down at the end of the test session, instead. This is an unintended side effect of the sessionloop test which may affect other tests in the test suite.Reducing the fixture scope from "package" to "module" results in the expected behaviour. The module was renamed to reflect the fact that the tests do not use a session scope.
Ignores subprocess tests when running on CPython 3.7.
When run with Python 3.7,
asyncio.subprocess.create_subprocess_exec
seems to be affected by an issue that prevents correct cleanup. Tests using pytest-trio will report that signal handling is already performed by another library and fail. [1] This is possibly a bug in CPython 3.7, so I suggest we ignore this test for that Python version.I've been shaving this yak for some time and this is my theory:
CPython 3.7 uses
asyncio.streams.StreamReader
andasyncio.streams.StreamWriter
to implementasyncio.streams.StreamReaderProtocol
andasyncio.subprocess.SubprocessStreamProtocol
.StreamReaderProtocol
contained cyclic references between the reader and the protocol, which prevented garbage collection. WhileStreamReaderProtocol
received a patch [2],SubprocessStreamProtocol
, which is used bycreate_subprocess_exec
, possibly has the same problem, but was not patched as part of CPython 3.7.[1] pytest-trio exits with TrioInternalError on Python 3.7 when pytest-asyncio is installed python-trio/pytest-trio#126
[2] bpo-34638: Store a weak reference to stream reader to break strong references loop python/cpython#9201