python-attrs / python-attrs/cattrs
[macOS] Error when trying to run tests: `ImportError: cannot import name 'CodecOptions' from 'bson'`
Open
Nobody has claimed this yet.
more-info-needed
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 159
- Avg merge
- 12h 21m
- Merged PRs (30d)
- 6
Description
- 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
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.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100