Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Don't warn about `asyncio_default_fixture_loop_scope` unless the test suite uses `pytest-asyncio`

Đang mở
#1,344 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
52/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
testing-qa

Hướng nghiên cứu

Bắt đầu với pytest_asyncio/plugin.py tại cảnh báo được báo cáo gần dòng 247 trong pytest_configure, sau đó tái hiện hành vi bằng cách sử dụng test_a.py và pytester.runpytest_inprocess. Chạy các lệnh pytest được liệt kê với pytest-asyncio đã được cài đặt; hoàn tất khi bộ kiểm thử không có test async chạy thành công với -Werror mà không xóa hoặc làm nhẹ cảnh báo deprecation khi pytest-asyncio thực sự được sử dụng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Hi all. I am not a user of pytest-asyncio, but it has gotten installed to my environment through one transitive dependency or another.

My test suite has no async tests and runs under -Werror. One of my tests uses pytester.runpytest_inprocess, which fails iff pytest-asyncio is installed due to the deprecation warning:

INTERNALERROR>   File "/Users/tybug/.local/share/uv/python/cpython-3.13.11-macos-aarch64-none/lib/python3.13/site-packages/pytest_asyncio/plugin.py", line 247, in pytest_configure
INTERNALERROR>     warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET))
INTERNALERROR>     ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> pytest.PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset.
INTERNALERROR> The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session"
================================================================= short test summary info ==================================================================
FAILED test_a.py::test_a - assert <ExitCode.INTERNAL_ERROR: 3> == 0
==================================================================== 1 failed in 0.06s =====================================================================
 ~/Desktop/pytest_inprocess_repro λ 

Reproduction steps:

mkdir pytest_asyncio_repro && cd pytest_asyncio_repro
uv venv .venv --python 3.12
uv pip install --python .venv/bin/python pytest pytest-asyncio
# test_a.py
pytest_plugins = ["pytester"]

def test_a(pytester):
    pytester.makepyfile(test_inner="""
def test_b(): pass
""")
    result = pytester.runpytest_inprocess()
    assert result.ret == 0
  • .venv/bin/python -m pytest test_a.py: passes
  • .venv/bin/python -m pytest test_a.py -Werror: fails

I'm not asking for the deprecation warning to be removed or relaxed. But it would be really great if having pytest-asyncio installed in my environment didn't cause my tests to fail!

I also don't know why this requires pytester.runpytest_inprocess to trigger. I would expect this to be a problem when running pytest at the top level as well. This may be why nobody has complained about this yet.

Ngôn ngữ chính
Python
Star
1.7k
Fork
211
Merge trung bình
5 giờ 2 phút
Pull request đã merge (30 ngày)
11

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của pytest-dev/pytest-asyncio

Tất cả issue của pytest-dev/pytest-asyncio

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.