Skip to content

Commit 32e6431

Browse files
committed
Update guard for pint import to possibly avoid recursion error on FreeBSD
1 parent 83066f8 commit 32e6431

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

pyomo/contrib/viewer/tests/test_data_model_item.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,10 @@
4646
from pyomo.contrib.viewer.model_browser import ComponentDataItem
4747
from pyomo.contrib.viewer.ui_data import UIData
4848
from pyomo.common.dependencies import DeferredImportError
49+
from pyomo.core.base.units_container import pint_available
4950

50-
try:
51-
x = pyo.units.m
52-
units_available = True
53-
except DeferredImportError:
54-
units_available = False
5551

56-
57-
@unittest.skipIf(not units_available, "Pyomo units are not available")
52+
@unittest.skipIf(not pint_available, "Pyomo units are not available")
5853
class TestDataModelItem(unittest.TestCase):
5954
def setUp(self):
6055
# Borrowed this test model from the trust region tests

pyomo/contrib/viewer/tests/test_data_model_tree.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,7 @@
4242
from pyomo.contrib.viewer.model_browser import ComponentDataModel
4343
import pyomo.contrib.viewer.qt as myqt
4444
from pyomo.common.dependencies import DeferredImportError
45-
46-
try:
47-
_x = pyo.units.m
48-
units_available = True
49-
except DeferredImportError:
50-
units_available = False
45+
from pyomo.core.base.units_container import pint_available
5146

5247
available = myqt.available
5348

@@ -63,7 +58,7 @@ def __init__(*args, **kwargs):
6358
pass
6459

6560

66-
@unittest.skipIf(not available or not units_available, "PyQt or units not available")
61+
@unittest.skipIf(not available or not pint_available, "PyQt or units not available")
6762
class TestDataModel(unittest.TestCase):
6863
def setUp(self):
6964
# Borrowed this test model from the trust region tests

0 commit comments

Comments
 (0)