Skip to content

Commit

Permalink
Test the import of all modules from pyomo._archive
Browse files Browse the repository at this point in the history
  • Loading branch information
jsiirola committed Nov 4, 2024
1 parent 622e99e commit 7f22b22
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pyomo/common/tests/test_deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import logging
import sys

from importlib import import_module
from importlib.machinery import ModuleSpec
from io import StringIO

Expand Down Expand Up @@ -761,6 +762,20 @@ def test_loader(self):
del sys.modules['pyomo.common.tests.old_moved']
del sys.modules['pyomo.common.tests.moved']

def test_archive_importable(self):
import pyomo.environ

# Check that all modules in the _archive directory are importable.
for old_name, info in MovedModuleFinder.mapping.items():
if '._archive.' in info.new_name:
with LoggingIntercept() as LOG:
m = import_module(info.old_name)
self.assertIn('DEPRECATED', LOG.getvalue())
# We expect every module in _archive to be depracated
# (and to state that in the module docstring):
self.assertIn('deprecated', m.__doc__)
self.assertEqual(m.__name__, info.new_name)


if __name__ == '__main__':
unittest.main()

0 comments on commit 7f22b22

Please sign in to comment.