Celery tests require package; test blows up if Celery not installed instead of skipping the tests gracefully

Aperta Adatta ai principianti
#750 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

@dchaudhari7177 ci sta già lavorando.

Dal 26/7/2026.

  • #752 di @dchaudhari7177 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
python
Ambito
testing-qa

Direzione di ricerca

Inizia da tests/test_pytest_cov.py, intorno a test_celery, e verifica come viene raccolto small_celery.py quando Celery non è disponibile. Esegui questo test in un ambiente senza Celery; il lavoro è completato quando il test viene ignorato correttamente invece di fallire durante la raccolta.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Summary

Expected vs actual result

Expected

Tests should be skipped if Celery isn't installed.

Actual

Tests blow up with an ImportError similar to what's provided at the bottom of the report.

Reproducer

Attempt to run tests on host without Celery installed.

Versions

% python3 -V; uname -sr
Python 3.12.13
FreeBSD 15.1-RELEASE-p1

Version being tested/installed is vanilla 7.1.0.

Config

n/a

Code

% cd devel/py-pytest-cov
% sudo make test
...

<...>/freebsd-ports/devel/py-pytest-cov/work-py312/pytest_cov-7.1.0/tests/test_pytest_cov.py:771: Failed
------------------------------------------------------------------------------------------------------------ Captured stdout call -------------------------------------------------------------------------------------------------------------
running: /usr/local/bin/python3.12 -mpytest --basetemp=/tmp/pytest-of-root/pytest-0/test_celery0/runpytest-0 -vv -s --cov --cov-report=term-missing small_celery.py --basetemp=/tmp/pytest-of-root/pytest-0/basetemp
     in: /tmp/pytest-of-root/pytest-0/test_celery0
============================= test session starts ==============================
platform freebsd15 -- Python 3.12.13, pytest-8.4.2, pluggy-1.6.0 -- /usr/local/bin/python3.12
cachedir: .pytest_cache
hypothesis profile 'default'
rootdir: /tmp/pytest-of-root/pytest-0/test_celery0
configfile: pyproject.toml
plugins: hypothesis-6.155.7, cov-7.1.0, xdist-3.8.0, flaky-3.8.1
collecting ... collected 0 items / 1 error

==================================== ERRORS ====================================
_______________________ ERROR collecting small_celery.py _______________________
ImportError while importing test module '/tmp/pytest-of-root/pytest-0/test_celery0/small_celery.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/local/lib/python3.12/site-packages/_pytest/python.py:498: in importtestmodule
    mod = import_path(
/usr/local/lib/python3.12/site-packages/_pytest/pathlib.py:587: in import_path
    importlib.import_module(module_name)
/usr/local/lib/python3.12/importlib/__init__.py:90: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
<frozen importlib._bootstrap>:1387: in _gcd_import
    ???
<frozen importlib._bootstrap>:1360: in _find_and_load
    ???
<frozen importlib._bootstrap>:1331: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:935: in _load_unlocked
    ???
/usr/local/lib/python3.12/site-packages/_pytest/assertion/rewrite.py:186: in exec_module
    exec(co, module.__dict__)
small_celery.py:3: in <module>
    from celery import Celery
E   ModuleNotFoundError: No module named 'celery'
=========================== short test summary info ============================
ERROR small_celery.py
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.48s ===============================
Lingua principale
Python
Stelle
2.1k
Fork
256
Merge medio
6g 10m
PR unite (30g)
2

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di pytest-dev/pytest-cov

Tutte le issue di pytest-dev/pytest-cov

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.