Closed speth closed 11 months ago
The bad part here is that the entire Python test suite fails as pint
cannot be imported ... @bryanwweber do you have an angle on how to prevent this from happening?
% scons test-python
[...]
=============================================== test session starts ===============================================
platform darwin -- Python 3.10.0, pytest-7.2.2, pluggy-1.2.0
rootdir: /Volumes/Data/work/GitHub/cantera/test/python, configfile: pytest.ini
plugins: anyio-3.7.1
collected 1867 items / 1 error
===================================================== ERRORS ======================================================
_________________________________________ ERROR collecting test_units.py __________________________________________
ImportError while importing test module '/Volumes/Data/work/GitHub/cantera/test/python/test_units.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/homebrew/Caskroom/miniforge/base/envs/cantera-dev/lib/python3.10/importlib/__init__.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
test/python/test_units.py:7: in <module>
import cantera.with_units as ctu
build/python/cantera/with_units/__init__.py:7: in <module>
from pint import UnitRegistry, set_application_registry
E ImportError: cannot import name 'UnitRegistry' from 'pint' (unknown location)
------------------- generated xml file: /Volumes/Data/work/GitHub/cantera/test/work/pytest.xml --------------------
============================================= short test summary info =============================================
ERROR test/python/test_units.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
================================================ 1 error in 0.38s =================================================
pytest allows you to importorskip
, I believe you can set that for the whole module. https://docs.pytest.org/en/7.1.x/how-to/skipping.html#skipping-on-a-missing-import-dependency
Problem description
The use of the Pint units library within the Cantera Python module is optional. However, attempting to run the Python test suite without Pint installed fails.
This is dissimilar to how we handle testing of other optional dependencies in Python, where we are able to use the
@pytest.mark.skipif
decorator.Steps to reproduce
scons test
Behavior
System information