PyO3 error
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- python
- Ambito
- testing-qa
Direzione di ricerca
Reproduce the failure with test_one.py, folder/init.py, folder/some_module.py, and the stated pytest command and package versions. Start by investigating how the --cov=folder.some_module entry point affects imports, then compare runs with and without --cov and with the listed dependency versions. Done means the cause is established and the reproducer no longer fails or the limitation is documented.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Hello,
I am currently debugging weird issue that happens to us only when using --cov arguments to pytest and only during running tests (not in production with the same code).
Reproducer
I was able to narrow it down for this little setup:
create this structure:
.
├── folder
│ ├── __init__.py
│ └── some_module.py
└── test_one.py
Now, some_module.py is empty.
folder/__init__.py has this content:
`from cryptography.hazmat.primitives import hashes`
test_one.py has this content:
`from cryptography.hazmat.primitives import hashes`
When you run this command (note that in my case the whole directory structure is in /home/vagrant/neto directory):
`PYTHONPATH=$PYTHONPATH:/home/vagrant/neto pytest /home/vagrant/neto/test_one.py --cov=folder.some_module`
you get
ImportError while importing test module '/home/vagrant/neto/test_one.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../.pyenv/versions/3.8.18/lib/python3.8/importlib/__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
test_one.py:2: in <module>
from cryptography.hazmat.primitives import hashes
../venv/pack/lib/python3.8/site-packages/cryptography/hazmat/primitives/hashes.py:10: in <module>
from cryptography.hazmat.bindings._rust import openssl as rust_openssl
E ImportError: PyO3 modules may only be initialized once per interpreter process
explanation
Reasons why I think (though not sure) the problem is in python-cov:
- you can switch
from cryptography.hazmat.primitives import hashesforimport jsonschemaand you get the into the same error. - we dont get any errors in production with the other imported packages.
- you remove the --cov attribute and it runs without errors.
- that importError sounds like that it might be caused by the way --cov path is handled internally?
versions
- python 3.8.18
- pytest 7.4.2
- pytest-cov 4.1.0
- jsonschema 4.19.1, problem doesnt appear when downgrading to 4.17.3
- cryptography 41.0.4, problem doesnt appear when downgrading to 40.0.2
- Lingua principale
- Python
- Stelle
- 2.1k
- Fork
- 256
- Merge medio
- 6g 10m
- PR unite (30g)
- 2
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
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-cov
-
Celery tests require package; test blows up if Celery not installed instead of skipping the tests gracefullyForse già presa @dchaudhari7177 l’ha presa 104 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
pytest-dev/pytest-cov#750 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
pytest-dev/pytest-cov#617 · 1 commento ·
-
Only set dynamic context on coveragepy cores supporting it, perhaps?Forse già presa @terminalchai l’ha presa 19 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
pytest-dev/pytest-cov#755 · 3 commenti ·
-
INTERNALERROR when generating html report using pytest-cov 7.1.0 with jinjaForse già presa @daleselaji-dev l’ha presa 90 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 58/100
pytest-dev/pytest-cov#748 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 28/100
pytest-dev/pytest-cov#747 · 1 reazione ·
Tutte le issue di pytest-dev/pytest-cov
Issue simili
-
[yugabyted] xcluster set_up and add_to_replication fail for database names containing - . or (Apertakind/bug priority/medium qa_automation
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
yugabyte/yugabyte-db#37324 ·
I maintainer di solito rispondono entro 1 giorno
-
good first issue
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 87/100
btclib-org/btclib-node#2260 ·
I maintainer di solito rispondono entro 1 giorno
-
ChatBedrockConverse changes the keys of JSON tool results to camelCase (`order_id` becomes `orderId`)Forse già presa @geyazheng l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
langchain-ai/langchain-aws#1469 ·
I maintainer di solito rispondono entro 1 giorno
-
GCToggler leaves collection enabled if the body re-enables itForse già presa @Gambit-Checkmate l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 7 giorni
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno