Fix testing and docs build failures

This commit is contained in:
Bryan Weber 2022-10-29 21:36:55 -04:00 committed by Ray Speth
parent c64773d7f4
commit d469ab2811
2 changed files with 15 additions and 5 deletions

View File

@ -300,7 +300,7 @@ jobs:
- name: Install Python dependencies
run: |
python3 -m pip install ruamel.yaml scons numpy cython sphinx\<4.0 jinja2\<3.1.0 \
sphinxcontrib-katex sphinxcontrib-matlabdomain sphinxcontrib-doxylink
sphinxcontrib-katex sphinxcontrib-matlabdomain sphinxcontrib-doxylink pint
- name: Build Cantera with documentation
run: python3 `which scons` build -j2 doxygen_docs=y sphinx_docs=y debug=n optimize=n use_pch=n
- name: Ensure 'scons help' options work

View File

@ -1,12 +1,16 @@
from contextlib import nullcontext
import pytest
from dataclasses import dataclass
from typing import Optional, Tuple, Dict
import sys
import pytest
import cantera.with_units as ctu
import cantera as ct
import numpy as np
try:
from pint.testing import assert_allclose
except ModuleNotFoundError:
# pint.testing was introduced in pint 0.20
from pint.testsuite.helpers import assert_quantity_almost_equal as assert_allclose
@pytest.fixture(scope="function")
@ -25,7 +29,13 @@ def generic_phase(request):
def test_setting_basis_units_fails(generic_phase):
with pytest.raises(AttributeError, match="basis_units"):
# Python 3.10 includes the name of the attribute which was improperly used as a
# setter. Earlier versions have just a generic error message.
if sys.version_info.minor < 10:
match = "set attribute"
else:
match = "basis_units"
with pytest.raises(AttributeError, match=match):
generic_phase.basis_units = "some random string"