From 0e9c34a5367a57c4bc8fc4cab6bcabb5f80a2aa4 Mon Sep 17 00:00:00 2001 From: Cedric Brandily Date: Thu, 16 Apr 2015 22:16:50 +0200 Subject: [PATCH] Correct mock use in TestCommandLineArgument.setUp TestCommandLineArgument.setUp mocks get_keystone_client using: shell.client.Client.get_keystone_client = mock.MagicMock() which is incorrect ... as the mock is not clean up during tearDown/cleanup. This change corrects how the mock is done. Closes-Bug: #1445197 Change-Id: If03a27f78fccd8bc5000b258f429dfb6f770f5ee --- magnumclient/tests/test_shell_args.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/magnumclient/tests/test_shell_args.py b/magnumclient/tests/test_shell_args.py index 10e3b093..d8069cc7 100644 --- a/magnumclient/tests/test_shell_args.py +++ b/magnumclient/tests/test_shell_args.py @@ -18,7 +18,6 @@ import mock from testtools import matchers from magnumclient import exceptions -from magnumclient import shell from magnumclient.tests import utils FAKE_ENV = {'OS_USERNAME': 'username', @@ -50,7 +49,10 @@ class TestCommandLineArgument(utils.TestCase): def setUp(self): super(TestCommandLineArgument, self).setUp() self.make_env(fake_env=FAKE_ENV) - shell.client.Client.get_keystone_client = mock.MagicMock() + keystone_mock = mock.patch( + 'magnumclient.v1.client.Client.get_keystone_client') + keystone_mock.start() + self.addCleanup(keystone_mock.stop) def _test_arg_success(self, command): stdout, stderr = self.shell(command)