File tree 3 files changed +47
-0
lines changed
3 files changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ # ___________________________________________________________________________
2
+ #
3
+ # Pyomo: Python Optimization Modeling Objects
4
+ # Copyright (c) 2008-2022
5
+ # National Technology and Engineering Solutions of Sandia, LLC
6
+ # Under the terms of Contract DE-NA0003525 with National Technology and
7
+ # Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
8
+ # rights in this software.
9
+ # This software is distributed under the 3-clause BSD License.
10
+ # ___________________________________________________________________________
11
+
12
+ from pyomo .common .deprecation import relocated_module
13
+
14
+ relocated_module ('pyomo.common.tests.relo_mod_new' , version = '1.2' )
Original file line number Diff line number Diff line change
1
+ # ___________________________________________________________________________
2
+ #
3
+ # Pyomo: Python Optimization Modeling Objects
4
+ # Copyright (c) 2008-2022
5
+ # National Technology and Engineering Solutions of Sandia, LLC
6
+ # Under the terms of Contract DE-NA0003525 with National Technology and
7
+ # Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
8
+ # rights in this software.
9
+ # This software is distributed under the 3-clause BSD License.
10
+ # ___________________________________________________________________________
11
+
12
+ RELO_ATTR = 42
13
+
14
+ class ReloClass (object ): pass
Original file line number Diff line number Diff line change @@ -425,6 +425,25 @@ def test_relocated_message(self):
425
425
"DEPRECATED: the 'oldName' class has been moved to "
426
426
"'pyomo.common.tests.test_deprecated.TestRelocated'" )
427
427
428
+ def test_relocated_module (self ):
429
+ with LoggingIntercept () as LOG :
430
+ # Can import attributes defined only in the new module
431
+ from pyomo .common .tests .relo_mod import ReloClass
432
+ self .assertRegex (
433
+ LOG .getvalue ().replace ('\n ' , ' ' ),
434
+ r"DEPRECATED: The 'pyomo\.common\.tests\.relo_mod' module has "
435
+ r"been moved to 'pyomo\.common\.tests\.relo_mod_new'. Please "
436
+ r"update your import. \(deprecated in 1\.2\) \(called from "
437
+ r".*/pyomo/common/tests/test_deprecated\.py" )
438
+ with LoggingIntercept () as LOG :
439
+ # Second import: no warning
440
+ import pyomo .common .tests .relo_mod as relo
441
+ self .assertEqual (LOG .getvalue (), '' )
442
+ import pyomo .common .tests .relo_mod_new as relo_new
443
+ self .assertIs (relo , relo_new )
444
+ self .assertEqual (relo .RELO_ATTR , 42 )
445
+ self .assertIs (ReloClass , relo_new .ReloClass )
446
+
428
447
429
448
class TestRenamedClass (unittest .TestCase ):
430
449
def test_renamed (self ):
You can’t perform that action at this time.
0 commit comments