Browse Source

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
tags/2.16.0
Zhongyue Luo 5 years ago
parent
commit
c71131a509
2 changed files with 3 additions and 6 deletions
  1. 3
    4
      novaclient/tests/v1_1/test_shell.py
  2. 0
    2
      novaclient/tests/v3/test_shell.py

+ 3
- 4
novaclient/tests/v1_1/test_shell.py View File

@@ -26,7 +26,6 @@ import six
26 26
 
27 27
 import novaclient.client
28 28
 from novaclient import exceptions
29
-from novaclient.openstack.common import timeutils
30 29
 import novaclient.shell
31 30
 from novaclient.tests import utils
32 31
 from novaclient.tests.v1_1 import fakes
@@ -69,7 +68,6 @@ class ShellTest(utils.TestCase):
69 68
         self.useFixture(fixtures.MonkeyPatch(
70 69
             'novaclient.client.get_client_class',
71 70
             lambda *_: fakes.FakeClient))
72
-        self.addCleanup(timeutils.clear_time_override)
73 71
 
74 72
     @mock.patch('sys.stdout', new_callable=six.StringIO)
75 73
     def run_command(self, cmd, mock_stdout):
@@ -1076,8 +1074,9 @@ class ShellTest(utils.TestCase):
1076 1074
                            'end=2005-02-01T00:00:00&' +
1077 1075
                            'detailed=1')
1078 1076
 
1079
-    def test_usage_list_no_args(self):
1080
-        timeutils.set_time_override(datetime.datetime(2005, 2, 1, 0, 0))
1077
+    @mock.patch('novaclient.openstack.common.timeutils.utcnow')
1078
+    def test_usage_list_no_args(self, mock_utcnow):
1079
+        mock_utcnow.return_value = datetime.datetime(2005, 2, 1, 0, 0)
1081 1080
         self.run_command('usage-list')
1082 1081
         self.assert_called('GET',
1083 1082
                            '/os-simple-tenant-usage?' +

+ 0
- 2
novaclient/tests/v3/test_shell.py View File

@@ -20,7 +20,6 @@ import fixtures
20 20
 import mock
21 21
 import six
22 22
 
23
-from novaclient.openstack.common import timeutils
24 23
 import novaclient.shell
25 24
 from novaclient.tests import utils
26 25
 from novaclient.tests.v3 import fakes
@@ -62,7 +61,6 @@ class ShellTest(utils.TestCase):
62 61
         self.useFixture(fixtures.MonkeyPatch(
63 62
             'novaclient.client.get_client_class',
64 63
             lambda *_: fakes.FakeClient))
65
-        self.addCleanup(timeutils.clear_time_override)
66 64
 
67 65
     @mock.patch('sys.stdout', new_callable=six.StringIO)
68 66
     def run_command(self, cmd, mock_stdout):

Loading…
Cancel
Save