From c71131a50994d95ae869442fc25e7c3511a5ddbc Mon Sep 17 00:00:00 2001 From: Zhongyue Luo Date: Thu, 9 Jan 2014 10:24:34 +0800 Subject: [PATCH] Removes use of timeutils.set_time_override The set_time_override function in timeutils was written as a helper function to mock utcnow for unittests before 'mock' was generally used. Now that we have mock and fixture, we no longer need to use it. Change-Id: I809825560b0324498010bd93aa1ceef552554375 Partial-Bug: #1266962 --- novaclient/tests/v1_1/test_shell.py | 7 +++---- novaclient/tests/v3/test_shell.py | 2 -- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/novaclient/tests/v1_1/test_shell.py b/novaclient/tests/v1_1/test_shell.py index 75af786a0..70d978f60 100644 --- a/novaclient/tests/v1_1/test_shell.py +++ b/novaclient/tests/v1_1/test_shell.py @@ -26,7 +26,6 @@ import six import novaclient.client from novaclient import exceptions -from novaclient.openstack.common import timeutils import novaclient.shell from novaclient.tests import utils from novaclient.tests.v1_1 import fakes @@ -69,7 +68,6 @@ class ShellTest(utils.TestCase): self.useFixture(fixtures.MonkeyPatch( 'novaclient.client.get_client_class', lambda *_: fakes.FakeClient)) - self.addCleanup(timeutils.clear_time_override) @mock.patch('sys.stdout', new_callable=six.StringIO) def run_command(self, cmd, mock_stdout): @@ -1076,8 +1074,9 @@ class ShellTest(utils.TestCase): 'end=2005-02-01T00:00:00&' + 'detailed=1') - def test_usage_list_no_args(self): - timeutils.set_time_override(datetime.datetime(2005, 2, 1, 0, 0)) + @mock.patch('novaclient.openstack.common.timeutils.utcnow') + def test_usage_list_no_args(self, mock_utcnow): + mock_utcnow.return_value = datetime.datetime(2005, 2, 1, 0, 0) self.run_command('usage-list') self.assert_called('GET', '/os-simple-tenant-usage?' + diff --git a/novaclient/tests/v3/test_shell.py b/novaclient/tests/v3/test_shell.py index 1c39ad7fd..b95e3820a 100644 --- a/novaclient/tests/v3/test_shell.py +++ b/novaclient/tests/v3/test_shell.py @@ -20,7 +20,6 @@ import fixtures import mock import six -from novaclient.openstack.common import timeutils import novaclient.shell from novaclient.tests import utils from novaclient.tests.v3 import fakes @@ -62,7 +61,6 @@ class ShellTest(utils.TestCase): self.useFixture(fixtures.MonkeyPatch( 'novaclient.client.get_client_class', lambda *_: fakes.FakeClient)) - self.addCleanup(timeutils.clear_time_override) @mock.patch('sys.stdout', new_callable=six.StringIO) def run_command(self, cmd, mock_stdout):