def test_removed_deprecated_runas(self): # We *always* want *all* warnings thrown on this module warnings.resetwarnings() warnings.filterwarnings('always', '', DeprecationWarning, __name__) mock = MagicMock(return_value={'retcode': 0, 'stdout': ''}) pip_list = MagicMock(return_value=['pep8']) pip_uninstall = MagicMock(return_value=True) with patch.dict(pip_state.__salt__, {'cmd.run_all': mock, 'pip.list': pip_list, 'pip.uninstall': pip_uninstall}): with warnings.catch_warnings(record=True) as w: ret = pip_state.removed('pep8', runas='me!') self.assertEqual( 'The \'runas\' argument to pip.installed is deprecated, ' 'and will be removed in Salt Hydrogen (Unreleased). ' 'Please use \'user\' instead.', str(w[-1].message) ) self.assertSaltTrueReturn({'testsuite': ret}) # Is the state returning a warnings key with the deprecation # message? self.assertInSalStatetWarning( 'The \'runas\' argument to pip.installed is deprecated, ' 'and will be removed in Salt Hydrogen (Unreleased). ' 'Please use \'user\' instead.', {'testsuite': ret} )
def test_removed_deprecated_runas(self): # We *always* want *all* warnings thrown on this module warnings.resetwarnings() warnings.filterwarnings('always', '', DeprecationWarning, __name__) mock = MagicMock(return_value={'retcode': 0, 'stdout': ''}) pip_list = MagicMock(return_value=['pep8']) pip_uninstall = MagicMock(return_value=True) with patch.dict( pip_state.__salt__, { 'cmd.run_all': mock, 'pip.list': pip_list, 'pip.uninstall': pip_uninstall }): with warnings.catch_warnings(record=True) as w: ret = pip_state.removed('pep8', runas='me!') self.assertEqual( 'The \'runas\' argument to pip.installed is deprecated, ' 'and will be removed in 0.18.0. Please use \'user\' ' 'instead.', str(w[-1].message)) self.assertSaltTrueReturn({'testsuite': ret}) # Is the state returning a warnings key with the deprecation # message? self.assertInSalStatetWarning( 'The \'runas\' argument to pip.installed is deprecated, ' 'and will be removed in 0.18.0. Please use \'user\' ' 'instead.', {'testsuite': ret})