From 114bd74fd2c4358ae16c0b86faf9b43c8d686344 Mon Sep 17 00:00:00 2001 From: Andrew Laski Date: Mon, 25 Mar 2013 13:38:28 -0400 Subject: [PATCH] Remove extraneous output during testing During shell tests commands were being passed to novaclient and output was being printed to stdout. This quickly scrolls useful test output offscreen, so lets suppress it. Also removed a print call from a test. Change-Id: I31c8bf2f92a64d781c9e3350213f2e1503b960ad --- tests/v1_1/contrib/test_tenant_networks.py | 1 - tests/v1_1/test_shell.py | 13 +++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/v1_1/contrib/test_tenant_networks.py b/tests/v1_1/contrib/test_tenant_networks.py index b66cc5b96..a96a83149 100644 --- a/tests/v1_1/contrib/test_tenant_networks.py +++ b/tests/v1_1/contrib/test_tenant_networks.py @@ -38,7 +38,6 @@ def test_list_tenant_networks(self): def test_get_tenant_network(self): net = cs.tenant_networks.get(1) cs.assert_called('GET', '/os-tenant-networks/1') - print(net) def test_create_tenant_networks(self): cs.tenant_networks.create(label="net", diff --git a/tests/v1_1/test_shell.py b/tests/v1_1/test_shell.py index 13b018a0e..4d67523f2 100644 --- a/tests/v1_1/test_shell.py +++ b/tests/v1_1/test_shell.py @@ -71,8 +71,10 @@ def setUp(self): lambda *_: fakes.FakeClient)) self.addCleanup(timeutils.clear_time_override) + @mock.patch('sys.stdout', StringIO.StringIO()) def run_command(self, cmd): self.shell.main(cmd.split()) + return sys.stdout.getvalue() def assert_called(self, method, url, body=None, **kwargs): return self.shell.cs.assert_called(method, url, body, **kwargs) @@ -488,15 +490,14 @@ def test_list_with_flavors(self): self.run_command('list --flavor 1') self.assert_called('GET', '/servers/detail?flavor=1') - @mock.patch('sys.stdout', StringIO.StringIO()) def test_list_fields(self): - self.run_command('list --fields ' + output = self.run_command('list --fields ' 'host,security_groups,OS-EXT-MOD:some_thing') self.assert_called('GET', '/servers/detail') - self.assertIn('computenode1', sys.stdout.getvalue()) - self.assertIn('securitygroup1', sys.stdout.getvalue()) - self.assertIn('OS-EXT-MOD: Some Thing', sys.stdout.getvalue()) - self.assertIn('mod_some_thing_value', sys.stdout.getvalue()) + self.assertIn('computenode1', output) + self.assertIn('securitygroup1', output) + self.assertIn('OS-EXT-MOD: Some Thing', output) + self.assertIn('mod_some_thing_value', output) def test_reboot(self): self.run_command('reboot sample-server')