def test_deprecated_callable(self): import deprecation_example.cc_module as m_new # Spoof module name. var_dict = dict(__name__="fake_module") _forward_callables_as_deprecated(var_dict, m_new, date="2038-01-19") with warnings.catch_warnings(record=True) as w: warnings.simplefilter("once", DrakeDeprecationWarning) obj = var_dict["ExampleCppClass"]() self.assertIsInstance(obj, m_new.ExampleCppClass) message_expected = ( "Please use ``deprecation_example.cc_module.ExampleCppClass`` " "instead of ``fake_module.ExampleCppClass``.") self.assertEqual(len(w), 1) self._check_warning(w[0], message_expected)
def test_deprecated_callable(self): import deprecation_example.cc_module as m_new # Spoof module name. var_dict = dict(__name__="fake_module") _forward_callables_as_deprecated(var_dict, m_new, "2050-01-01") with warnings.catch_warnings(record=True) as w: warnings.simplefilter("once", DrakeDeprecationWarning) obj = var_dict["ExampleCppClass"]() self.assertIsInstance(obj, m_new.ExampleCppClass) message_expected = ( "``fake_module.ExampleCppClass`` is deprecated and will be " "removed on or around 2050-01-01; please use " "``deprecation_example.cc_module.ExampleCppClass`` instead.") self.assertEqual(len(w), 1) self._check_warning(w[0], message_expected)
def test_deprecated_callable(self): import deprecation_example.cc_module as m_new # Spoof module name. var_dict = dict(__name__="fake_module") _forward_callables_as_deprecated(var_dict, m_new, "2050-01-01") with warnings.catch_warnings(record=True) as w: warnings.simplefilter("once", DrakeDeprecationWarning) obj = var_dict["ExampleCppClass"]() self.assertIsInstance(obj, m_new.ExampleCppClass) message_expected = ( "``fake_module.ExampleCppClass`` is deprecated and will be " "removed on or around 2050-01-01; please use " "``deprecation_example.cc_module.ExampleCppClass`` instead.") self.assertEqual(len(w), 1) self._check_warning(w[0], message_expected)
from pydrake.common.deprecation import _forward_callables_as_deprecated # Only try to import attic symbols if they're available. try: from pydrake.attic.systems import controllers as _attic _forward_callables_as_deprecated(locals(), _attic, "2019-05-01") except ImportError: pass