summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug Hellmann <doug@doughellmann.com>2015-07-10 12:39:46 +0000
committerDoug Hellmann <doug@doughellmann.com>2015-07-12 19:03:45 +0000
commit061ab839969cd089dd3c70bd5e2cd4344dc11795 (patch)
tree9138aee6306dba43105da3e59e64f5eefd9f3752
parent781868f2dacc06814ccf5af755d8fee139479767 (diff)
downloadoslo-config-061ab839969cd089dd3c70bd5e2cd4344dc11795.tar.gz
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
-rw-r--r--oslo_config/tests/test_cfg.py4
-rw-r--r--test-requirements.txt3
-rw-r--r--tests/test_cfg.py6
3 files changed, 7 insertions, 6 deletions
diff --git a/oslo_config/tests/test_cfg.py b/oslo_config/tests/test_cfg.py
index 28226e7..60f9526 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 1a68205..7261313 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 6b65788..6e72600 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'))