Skip to content

Warning about asyncio_mode even when unused in tests. #293

Closed
@cladmi

Description

@cladmi

When pytest-asyncio is installed, it would warn about its configuration even if nothings makes use of it in the test suite.
Meaning all tests on my machine would need to have the asyncio_mode configuration, even if not using it, to not have a warning reported.
(in a non virtualenv environment, I agree).

It would be nice to only warn if it's actually used in a test.

With a clean directory with only a bare test, and pytest-asyncio installed in the user directory:

python3 -m pip freeze | grep asyncio
pytest-asyncio==0.18.1
# test_lala.py 
def test_lala():
    pass
pytest
========================================= test session starts ==========================================
platform linux -- Python 3.8.10, pytest-6.1.2, py-1.9.0, pluggy-0.13.1
rootdir: /home/gha/empty
plugins: html-3.1.1, cov-2.12.1, asyncio-0.18.1, requests-mock-1.9.3, metadata-1.11.0
asyncio: mode=legacy
collected 1 item                                                                                       

test_lala.py .                                                                                   [100%]

=========================================== warnings summary ===========================================
../.local/lib/python3.8/site-packages/pytest_asyncio/plugin.py:191
  /home/gha/.local/lib/python3.8/site-packages/pytest_asyncio/plugin.py:191: DeprecationWarning: The 'asyncio_mode' default value will change to 'strict' in future, please explicitly use 'asyncio_mode=strict' or 'asyncio_mode=auto' in pytest configuration file.
    config.issue_config_time_warning(LEGACY_MODE, stacklevel=2)

-- Docs: https://docs.pytest.org/en/stable/warnings.html
===================================== 1 passed, 1 warning in 0.01s =====================================

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions