Skip to content

Commit

Permalink
Merge pull request #3277 from jsiirola/update-pint-guard
Browse files Browse the repository at this point in the history
Update guard for pint import to possibly avoid recursion error
  • Loading branch information
blnicho authored May 29, 2024
2 parents 83066f8 + 32e6431 commit 18e80b5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
9 changes: 2 additions & 7 deletions pyomo/contrib/viewer/tests/test_data_model_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,10 @@
from pyomo.contrib.viewer.model_browser import ComponentDataItem
from pyomo.contrib.viewer.ui_data import UIData
from pyomo.common.dependencies import DeferredImportError
from pyomo.core.base.units_container import pint_available

try:
x = pyo.units.m
units_available = True
except DeferredImportError:
units_available = False


@unittest.skipIf(not units_available, "Pyomo units are not available")
@unittest.skipIf(not pint_available, "Pyomo units are not available")
class TestDataModelItem(unittest.TestCase):
def setUp(self):
# Borrowed this test model from the trust region tests
Expand Down
9 changes: 2 additions & 7 deletions pyomo/contrib/viewer/tests/test_data_model_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,7 @@
from pyomo.contrib.viewer.model_browser import ComponentDataModel
import pyomo.contrib.viewer.qt as myqt
from pyomo.common.dependencies import DeferredImportError

try:
_x = pyo.units.m
units_available = True
except DeferredImportError:
units_available = False
from pyomo.core.base.units_container import pint_available

available = myqt.available

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


@unittest.skipIf(not available or not units_available, "PyQt or units not available")
@unittest.skipIf(not available or not pint_available, "PyQt or units not available")
class TestDataModel(unittest.TestCase):
def setUp(self):
# Borrowed this test model from the trust region tests
Expand Down

0 comments on commit 18e80b5

Please sign in to comment.