Skip to content

PytestAssertRewriteWarning due to runpytest and pytest_plugins #1334

@McSinyx

Description

@McSinyx

Originally posted by @McSinyx in #1275 (comment)

On Python 3.11 on Guix (full test log), PytestAssertRewriteWarning resurfaces for the following tests due to 18afc9d replacing runpytest with runpytest_subprocess:

tests/markers/test_class_scope.py::test_standalone_test_does_not_trigger_warning_about_no_current_event_loop_being_set
tests/markers/test_function_scope.py::test_warns_when_scope_argument_is_present
tests/markers/test_module_scope.py::test_standalone_test_does_not_trigger_warning_about_no_current_event_loop_being_set
tests/markers/test_session_scope.py::test_standalone_test_does_not_trigger_warning_about_no_current_event_loop_being_set
tests/test_event_loop_fixture.py::test_event_loop_fixture_handles_unclosed_async_gen
tests/test_event_loop_fixture.py::test_event_loop_fixture_asyncgen_error

IIUC this commit tries to workaround a case in GH-1227 where a system pytest-asyncio package takes precedence over a local one. Our fix for Guix also involves removing pytest_plugins = 'pytest_asyncio' in the following tests because it also marks the package for assertion rewriting while it's already imported before executing the scripts as part of plugin autodiscovery.

tests/test_event_loop_fixture.py::test_event_loop_fixture_handles_unclosed_async_gen
tests/test_event_loop_fixture.py::test_event_loop_fixture_asyncgen_error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions