From 061ab839969cd089dd3c70bd5e2cd4344dc11795 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 10 Jul 2015 12:39:46 +0000 Subject: [PATCH] Fix use of mock for 1.1.0 Correctly assert the number of calls to a mocked method. Combine this with the change to pin the version of mock used for python 2.6 and raise the minimum version of mock used elsewhere. Change-Id: I8cf1936f06f489561a59ec3cc75a1a8d6419a9ef --- oslo_config/tests/test_cfg.py | 4 ++-- test-requirements.txt | 3 ++- tests/test_cfg.py | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/oslo_config/tests/test_cfg.py b/oslo_config/tests/test_cfg.py index 28226e79..60f9526c 100644 --- a/oslo_config/tests/test_cfg.py +++ b/oslo_config/tests/test_cfg.py @@ -946,7 +946,7 @@ class ConfigFileOptsTestCase(BaseTestCase): @mock.patch.object(cfg, 'LOG') def test_conf_file_int_wrong_default(self, mock_log): cfg.IntOpt('foo', default='666') - mock_log.debug.assert_call_count(1) + self.assertEqual(1, mock_log.debug.call_count) def test_conf_file_int_value(self): self.conf.register_opt(cfg.IntOpt('foo')) @@ -1025,7 +1025,7 @@ class ConfigFileOptsTestCase(BaseTestCase): @mock.patch.object(cfg, 'LOG') def test_conf_file_float_default_wrong_type(self, mock_log): cfg.FloatOpt('foo', default='foobar6.66') - mock_log.debug.assert_call_count(1) + self.assertEqual(1, mock_log.debug.call_count) def test_conf_file_float_value(self): self.conf.register_opt(cfg.FloatOpt('foo')) diff --git a/test-requirements.txt b/test-requirements.txt index 1a68205f..72613130 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -25,4 +25,5 @@ oslosphinx>=2.5.0 # Apache-2.0 oslo.i18n>=1.5.0 # Apache-2.0 # mocking framework -mock>=1.0 +mock>=1.1;python_version!='2.6' +mock==1.0.1;python_version=='2.6' diff --git a/tests/test_cfg.py b/tests/test_cfg.py index 6b65788c..6e726002 100644 --- a/tests/test_cfg.py +++ b/tests/test_cfg.py @@ -951,7 +951,7 @@ class ConfigFileOptsTestCase(BaseTestCase): @mock.patch('oslo_config.cfg.LOG') def test_conf_file_int_wrong_default(self, mock_log): cfg.IntOpt('foo', default='666') - mock_log.debug.assert_call_count(1) + self.assertEqual(1, mock_log.debug.call_count) def test_conf_file_int_value(self): self.conf.register_opt(cfg.IntOpt('foo')) @@ -1027,10 +1027,10 @@ class ConfigFileOptsTestCase(BaseTestCase): self.assertTrue(hasattr(self.conf, 'foo')) self.assertEqual(self.conf.foo, 6.66) - @mock.patch.object(cfg, 'LOG') + @mock.patch('oslo_config.cfg.LOG') def test_conf_file_float_default_wrong_type(self, mock_log): cfg.FloatOpt('foo', default='foobar6.66') - mock_log.debug.assert_call_count(1) + self.assertEqual(1, mock_log.debug.call_count) def test_conf_file_float_value(self): self.conf.register_opt(cfg.FloatOpt('foo'))