Align mocking pattern for test case
Mock sys.stderr/sys.stdout with mock.patch() In novaclient/tests/test_shell.py, ShellTest.shell(), it is another case that should be aligned. But it may induce test error if changed. So, let's keep it as is. Close-Bug #1237093 Change-Id: I8908dc1593dbbbaf2813cc8fb034be32972140a0
This commit is contained in:
parent
5f0363ad9d
commit
b1e3753fdf
@ -644,19 +644,12 @@ class ShellTest(utils.TestCase):
|
||||
self.run_command('image-meta 1 delete test_key=test_value')
|
||||
self.assert_called('DELETE', '/images/1/metadata/test_key')
|
||||
|
||||
@mock.patch('sys.stdout', six.StringIO())
|
||||
@mock.patch('sys.stderr', six.StringIO())
|
||||
def test_image_meta_bad_action(self):
|
||||
tmp = six.StringIO()
|
||||
|
||||
# Suppress stdout and stderr
|
||||
(stdout, stderr) = (sys.stdout, sys.stderr)
|
||||
(sys.stdout, sys.stderr) = (tmp, tmp)
|
||||
|
||||
self.assertRaises(SystemExit, self.run_command,
|
||||
'image-meta 1 BAD_ACTION test_key=test_value')
|
||||
|
||||
# Put stdout and stderr back
|
||||
sys.stdout, sys.stderr = (stdout, stderr)
|
||||
|
||||
def test_image_list(self):
|
||||
self.run_command('image-list')
|
||||
self.assert_called('GET', '/images/detail')
|
||||
|
Loading…
x
Reference in New Issue
Block a user