Be compatible with mock 0.7

This commit is contained in:
Jeroen Dekkers 2012-06-19 02:19:03 +02:00
parent 9dd57c057e
commit 92ffbaba6e
2 changed files with 10 additions and 6 deletions

View File

@ -47,7 +47,8 @@ rvm rubies
# * - default
'''
with patch.object(rvm, '_rvm', return_value=list_output):
with patch.object(rvm, '_rvm') as mock_method:
mock_method.return_value = list_output
self.assertEqual(
[['jruby', '1.6.5.1', False],
['ree', '1.8.7-2011.03', False],
@ -66,7 +67,8 @@ gemsets for ree-1.8.7-2012.02 (found in /usr/local/rvm/gems/ree-1.8.7-2012.02)
foo
'''
with patch.object(rvm, '_rvm_do', return_value=output):
with patch.object(rvm, '_rvm_do') as mock_method:
mock_method.return_value = output
self.assertEqual(
['global', 'bar', 'foo'],
rvm.gemset_list())
@ -97,7 +99,8 @@ gemsets for ruby-1.9.2-p180 (found in /usr/local/rvm/gems/ruby-1.9.2-p180)
'''
with patch.object(rvm, '_rvm_do', return_value=output):
with patch.object(rvm, '_rvm_do') as mock_method:
mock_method.return_value = output
self.assertEqual(
{'jruby-1.6.5.1': ['global', 'jbar', 'jfoo'],
'ruby-1.9.2-p180': ['global'],

View File

@ -54,8 +54,8 @@ class TestRvmState(TestCase):
self.assertEqual(result, ret['result'])
def test_gemset_present(self):
with patch.object(rvm, '_check_rvm',
return_value={'result': True, 'changes': {}}):
with patch.object(rvm, '_check_rvm') as mock_method:
mock_method.return_value = {'result': True, 'changes': {}}
gems = ['global', 'foo', 'bar']
gemset_list = MagicMock(return_value=gems)
gemset_create = MagicMock(return_value=True)
@ -75,7 +75,8 @@ class TestRvmState(TestCase):
def test_installed(self):
mock = MagicMock()
with patch.object(rvm, '_check_rvm', return_value={'result': True}):
with patch.object(rvm, '_check_rvm') as mock_method:
mock_method.return_value = {'result': True}
with patch.object(rvm, '_check_and_install_ruby', new=mock):
rvm.installed("1.9.3", default=True)
mock.assert_called_once_with(