Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

[macOS] Error when trying to run tests: `ImportError: cannot import name 'CodecOptions' from 'bson'`

Abierto
#523 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
28/100
Tipo de issue
Error
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
python
Área
testing

Línea de trabajo

Reproduce the reported command, py.test-3.12 -o addopts='', in the cattrs 23.2.3 checkout and inspect the failing import in tests/test_preconf.py. Check the installed bson package and project test dependencies; done means test collection no longer fails with the reported CodecOptions ImportError, with the supported setup made clear.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

more-info-needed
  • cattrs version: 23.2.3
  • Python version: 3.12
  • Operating System: macOS 10.6
Description

Running tests does not seem to work.

What I Did
--->  Testing py312-cattrs
Executing:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_python_py-cattrs/py312-cattrs/work/cattrs-23.2.3" && py.test-3.12 -o addopts='' 
============================= test session starts ==============================
platform darwin -- Python 3.12.2, pytest-7.4.3, pluggy-1.3.0
benchmark: 4.0.0 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_python_py-cattrs/py312-cattrs/work/cattrs-23.2.3
configfile: pyproject.toml
plugins: hypothesis-6.92.1, benchmark-4.0.0
collected 626 items / 1 error

==================================== ERRORS ====================================
____________________ ERROR collecting tests/test_preconf.py ____________________
ImportError while importing test module '/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_python_py-cattrs/py312-cattrs/work/cattrs-23.2.3/tests/test_preconf.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/__init__.py:90: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_preconf.py:11: in <module>
    from bson import CodecOptions, ObjectId
E   ImportError: cannot import name 'CodecOptions' from 'bson' (/opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/bson/__init__.py)
=============================== warnings summary ===============================
tests/typed.py:417
  /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_python_py-cattrs/py312-cattrs/work/cattrs-23.2.3/tests/typed.py:417: HypothesisWarning: Return-type annotation is `st.SearchStrategy[typing.Tuple[attr._make._CountingAttr, st.SearchStrategy]]`, but the decorated function should return a value (not a strategy)
    @composite

tests/typed.py:826
  /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_python_py-cattrs/py312-cattrs/work/cattrs-23.2.3/tests/typed.py:826: HypothesisWarning: Return-type annotation is `st.SearchStrategy[typing.Tuple[typing.Type, st.SearchStrategy[typing.Tuple[typing.Any]], st.SearchStrategy[typing.Dict[str, typing.Any]]]]`, but the decorated function should return a value (not a strategy)
    @composite

../../../../../../../Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dateutil/tz/tz.py:37
  /opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dateutil/tz/tz.py:37: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
    EPOCH = datetime.datetime.utcfromtimestamp(0)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
ERROR tests/test_preconf.py
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
========================= 3 warnings, 1 error in 6.83s =========================
Command failed:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_python_py-cattrs/py312-cattrs/work/cattrs-23.2.3" && py.test-3.12 -o addopts='' 
Exit code: 2
Lenguaje dominante
Python
Estrellas
1.1k
Forks
168
Merge medio
2 d 13 h
PR fusionados (30 d)
7

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de python-attrs/cattrs

Todos los issues de python-attrs/cattrs

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.