Skip to content

Commit

Permalink
[Python/Test] Work around pint TypeError
Browse files Browse the repository at this point in the history
Set up unit tests to be skipped if pint can't be imported. There is a known bug with pint and Python 3.13 that prevents importorskip from working.
  • Loading branch information
bryanwweber authored and speth committed Aug 2, 2024
1 parent edf7bb8 commit dd03a35
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions test/python/test_units.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
from contextlib import nullcontext
from dataclasses import dataclass
from typing import Optional, Tuple, Dict
import sys

import pytest
pytest.importorskip("pint", "0.17.0")
try:
pint = pytest.importorskip("pint", "0.17.0")
except TypeError as e:
# The extra exception handling is here because pint is incompatible with
# Python 3.13. Once https://github.com/hgrecco/pint/issues/1969 is resolved the
# try/except here can be restored to just the importorskip.
pytest.skip(f"pint import failed due to {e}", allow_module_level=True)
import cantera.with_units as ctu
import cantera as ct
try:
Expand Down

0 comments on commit dd03a35

Please sign in to comment.