LGTM, thanks for catching this bug!

On Thu, Jun 9, 2016 at 11:33 PM, Iustin Pop <ius...@k1024.org> wrote:

> From: Iustin Pop <ius...@google.com>
>
> Old versions of mock were not strict, thus allowing to call any method on
> mocked objects, without complaining. More recent mock versions are
> stricter,
> and have uncovered this latent testing bug: assert_called_once() doesn't
> exist,
> only assert_called_once_with(…). Fixup the code to call that instead.
>
> A funny and ranty explanation of this is at
>
> http://engineeringblog.yelp.com/2015/02/assert_called_once-threat-or-menace.html
> .
>
> Signed-off-by: Iustin Pop <ius...@google.com>
> ---
>  test/py/cmdlib/test_unittest.py        | 2 +-
>  test/py/ganeti.utils.retry_unittest.py | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/test/py/cmdlib/test_unittest.py
> b/test/py/cmdlib/test_unittest.py
> index f93f99d..16cc092 100644
> --- a/test/py/cmdlib/test_unittest.py
> +++ b/test/py/cmdlib/test_unittest.py
> @@ -85,7 +85,7 @@ class TestLUTestDelay(CmdlibTestCase):
>
>      self.ExecOpCode(op)
>
> -    self.rpc.call_test_delay.assert_called_once()
> +    self.rpc.call_test_delay.assert_called_once_with([self.master_uuid],
> DELAY_DURATION)
>
>    def testFailingRpc(self):
>      op = opcodes.OpTestDelay(duration=DELAY_DURATION,
> diff --git a/test/py/ganeti.utils.retry_unittest.py b/test/py/
> ganeti.utils.retry_unittest.py
> index 93638cd..8a53760 100755
> --- a/test/py/ganeti.utils.retry_unittest.py
> +++ b/test/py/ganeti.utils.retry_unittest.py
> @@ -215,7 +215,7 @@ class
> TestRetryByNumberOfTimes(testutils.GanetiTestCase):
>    def testSuccessOnFirst(self):
>      test_fn = mock.Mock()
>      utils.RetryByNumberOfTimes(5, 0, Exception, test_fn)
> -    test_fn.assert_called_once()
> +    test_fn.assert_called_once_with()
>
>    def testSuccessOnFirstWithArgs(self):
>      test_fn = mock.Mock()
> --
> 2.8.1
>
>

Reply via email to