"The test […] is not an async function" when `asyncio` marker is added via `pytest_collection_modifyitems()`
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
- #1379 của @JiwaniZakir — đã đóng, không merge
Đá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
- 55/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- python
- Lĩnh vực
- testing-qa
Hướng nghiên cứu
Bắt đầu với reproducer trong conftest.py và test_foo.py, sau đó kiểm tra cách pytest-asyncio xử lý các marker được thêm bởi pytest_collection_modifyitems(). So sánh hành vi giữa pytest-asyncio 0.23.6 và 0.21.1. Được xem là hoàn tất khi bài kiểm thử async được nhận diện và thực thi khi marker asyncio được thêm trong quá trình collection, mà không có cảnh báo được hiển thị.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
This one I've noticed while testing IPython. The simplest reproducer is:
conftest.py:
import inspect
def pytest_collection_modifyitems(items):
for item in items:
if inspect.iscoroutinefunction(item.obj):
item.add_marker("asyncio")
test_foo.py:
async def test_foo():
pass
With pytest-asyncio 0.23.6, I'm getting:
========================================================= test session starts =========================================================
platform linux -- Python 3.11.8, pytest-8.1.1, pluggy-1.4.0
rootdir: /tmp/repro
plugins: asyncio-0.23.6
asyncio: mode=Mode.STRICT
collected 1 item
test_foo.py s [100%]
========================================================== warnings summary ===========================================================
test_foo.py::test_foo
test_foo.py:5: PytestWarning: The test <Function test_foo> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove the asyncio mark. If the test is not marked explicitly, check for global marks applied via 'pytestmark'.
async def test_foo():
test_foo.py::test_foo
/tmp/repro/.venv/lib/python3.11/site-packages/_pytest/python.py:184: PytestUnhandledCoroutineWarning: async def functions are not natively supported and have been skipped.
You need to install a suitable plugin for your async framework, for example:
- anyio
- pytest-asyncio
- pytest-tornasync
- pytest-trio
- pytest-twisted
warnings.warn(PytestUnhandledCoroutineWarning(msg.format(nodeid)))
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=================================================== 1 skipped, 2 warnings in 0.01s ====================================================
With pytest-asyncio-0.21.1, the test is correctly run as marked.
- Ngôn ngữ chính
- Python
- Star
- 1.7k
- Fork
- 209
- Merge trung bình
- 3 giờ 29 phút
- Pull request đã merge (30 ngày)
- 15
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
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của pytest-dev/pytest-asyncio
-
Turn deprecation of the "scope" keyword argument of the asyncio marker into an errorCó thể đã có người làm @mokashang đã nhận 121 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
pytest-dev/pytest-asyncio#1475 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 56/100
pytest-dev/pytest-asyncio#1514 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Loop factory parametrization tears down async fixtures used by sync testsCó thể đã có người làm @TLNing260310 đã nhận 49 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
pytest-dev/pytest-asyncio#1501 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`pytest_asyncio_loop_factories` hook is not called when `pytest.mark.asyncio` is added via parametrizationCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
pytest-dev/pytest-asyncio#1463 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Don't warn about `asyncio_default_fixture_loop_scope` unless the test suite uses `pytest-asyncio`Có thể làm lại được @DawnofGenX đã nhận 13 ngày trước và không có pull request nào đang mở. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 52/100
pytest-dev/pytest-asyncio#1344 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của pytest-dev/pytest-asyncio
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
mihai-vlc/sublime-jsfmt#56 ·
-
comp/cli comp/plugins P2 type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
NousResearch/hermes-agent#141917 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Go device SDK: Whisper transcriber keeps buffering and transcribing audio appended after Stop()Có thể đã có người làm @apoorvdarshan đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
BasedHardware/omi#22770 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug needs-acceptance wg/router-models-inference-runtime
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
vllm-project/semantic-router#5295 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
huggingface/huggingface_hub#5210 ·
Maintainer thường phản hồi trong vòng 1 ngày