From c7b31385ac3616060ef0f2188fb724191caad03c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 10 Jul 2015 12:22:26 +0000 Subject: [PATCH] Fix mock use for mock 1.1.0 Correct the way we check the calls by using the proper mock method. Add a new test to expand coverage of the area being fixed. Change-Id: I344ee52dd0ea77bc45b6d3e2713ae1ba8b225ffc --- oslo_messaging/tests/test_utils.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/oslo_messaging/tests/test_utils.py b/oslo_messaging/tests/test_utils.py index 22178d8ea..1dd9d4a8d 100644 --- a/oslo_messaging/tests/test_utils.py +++ b/oslo_messaging/tests/test_utils.py @@ -84,4 +84,16 @@ class TimerTestCase(test_utils.BaseTestCase): callback = mock.Mock() remaining = t.check_return(callback) self.assertEqual(0, remaining) - callback.assert_called_once + callback.assert_called_once_with() + + @mock.patch('oslo_utils.timeutils.now') + def test_duration_callback_with_args(self, now): + now.return_value = 0 + t = common.DecayingTimer(2) + t.start() + + now.return_value = 3 + callback = mock.Mock() + remaining = t.check_return(callback, 1, a='b') + self.assertEqual(0, remaining) + callback.assert_called_once_with(1, a='b')