How do I know if a test function is async?
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
Inizia con pytest_generate_tests e il passaggio del README che descrive async_mode=auto e l’inserimento automatico dei marker. Traccia quando viene valutato metafunc.definition.get_closest_marker("asyncio") rispetto al wrapping, quindi verifica il comportamento con un test pytest-asyncio mirato. Il lavoro è completato quando il comportamento documentato dei marker è coerente con quello osservato e il test copre la modalità auto asincrona.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Hey there, thanks for the awesome work. :)
I'm trying to check if a function is async or not within pytest_generate_tests. I'm using async_mode=auto and I would like to keep it that way.
My first bet was to simply use inspect.isawaitable(metafunc.function), but I quickly understood that pytest-asyncio wraps my async test functions into synchronous ones, which makes sense.
So the next thing I tried was:
def pytest_generate_tests(metafunc):
if metafunc.definition.get_closest_marker("asyncio"):
...
I would have expected this one to work, because the README says it should:
In auto mode, the
pytest.mark.asynciomarker can be omitted, the marker is added automatically to async test functions.
So either there's something obvious I'm missing here, or the README is wrong.
What I'm doing right now (but that's really just a hack):
def pytest_generate_tests(metafunc):
if inspect.getsource(metafunc.function)[0:5] == "async":
...
Is there any better way right now? If not, do you want me to open a PR to automatically mark async test functions with pytest.mark.asyncio when using async_mode=auto?
Cheers!
- Lingua principale
- Python
- Stelle
- 1.7k
- Fork
- 209
- Merge medio
- 1h 51m
- PR unite (30g)
- 13
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di pytest-dev/pytest-asyncio
-
Turn deprecation of the "scope" keyword argument of the asyncio marker into an errorForse già presa @mokashang l’ha presa 119 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
pytest-dev/pytest-asyncio#1475 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 56/100
pytest-dev/pytest-asyncio#1514 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Loop factory parametrization tears down async fixtures used by sync testsForse già presa @TLNing260310 l’ha presa 47 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
pytest-dev/pytest-asyncio#1501 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
`pytest_asyncio_loop_factories` hook is not called when `pytest.mark.asyncio` is added via parametrizationForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
pytest-dev/pytest-asyncio#1463 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Don't warn about `asyncio_default_fixture_loop_scope` unless the test suite uses `pytest-asyncio`Forse di nuovo libera @DawnofGenX l’ha presa 11 giorni fa e non c’è nessuna pull request aperta. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
pytest-dev/pytest-asyncio#1344 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di pytest-dev/pytest-asyncio
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
NousResearch/hermes-agent#140958 ·
I maintainer di solito rispondono entro 1 giorno
-
Bisect issue233186Apertabisect
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
dtcxzyw/llvm-bisect-service#548 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
sallowayma-git/IELTS-practice#248 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 65/100
anthropics/claude-plugins-official#6763 · 10 commenti · 10 reazioni ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno