From 48ff4082223ff6d2a075b1cf8097709064118e2b Mon Sep 17 00:00:00 2001 From: Ghe Rivero Date: Mon, 18 Nov 2013 12:36:32 +0000 Subject: [PATCH] Comply with new hacking requirements With new hacking>=0.8.0,<0.9 requirements, some functions are now deprecated. assertEquals -> assertEqual assertNotEquals -> assertNotEqual Change-Id: I70287b0c8561a901069bddcf3007751c34a4e0b5 --- os_collect_config/tests/test_cache.py | 4 ++-- os_collect_config/tests/test_cfn.py | 22 +++++++++--------- os_collect_config/tests/test_collect.py | 26 +++++++++++----------- os_collect_config/tests/test_ec2.py | 8 +++---- os_collect_config/tests/test_heat_local.py | 4 ++-- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/os_collect_config/tests/test_cache.py b/os_collect_config/tests/test_cache.py index 680b67f..463c18f 100644 --- a/os_collect_config/tests/test_cache.py +++ b/os_collect_config/tests/test_cache.py @@ -58,7 +58,7 @@ class TestCache(testtools.TestCase): orig_path = '%s.orig' % path with open(path) as now: with open(orig_path) as then: - self.assertNotEquals(now.read(), then.read()) + self.assertNotEqual(now.read(), then.read()) # Saves the current copy as .last cache.commit('foo') @@ -84,4 +84,4 @@ class TestCache(testtools.TestCase): self.assertIn(path, list_list) def test_commit_no_cache(self): - self.assertEquals(None, cache.commit('neversaved')) + self.assertEqual(None, cache.commit('neversaved')) diff --git a/os_collect_config/tests/test_cfn.py b/os_collect_config/tests/test_cfn.py index abc5e75..e7a2e04 100644 --- a/os_collect_config/tests/test_cfn.py +++ b/os_collect_config/tests/test_cfn.py @@ -62,18 +62,18 @@ class FakeRequests(object): def get(self, url, params, headers): self._test.addDetail('url', test_content.text_content(url)) url = urlparse.urlparse(url) - self._test.assertEquals(self._expected_netloc, url.netloc) - self._test.assertEquals('/v1/', url.path) - self._test.assertEquals('application/json', - headers['Content-Type']) + self._test.assertEqual(self._expected_netloc, url.netloc) + self._test.assertEqual('/v1/', url.path) + self._test.assertEqual('application/json', + headers['Content-Type']) self._test.assertIn('SignatureVersion', params) - self._test.assertEquals('2', params['SignatureVersion']) + self._test.assertEqual('2', params['SignatureVersion']) self._test.assertIn('Signature', params) self._test.assertIn('Action', params) - self._test.assertEquals('DescribeStackResource', - params['Action']) + self._test.assertEqual('DescribeStackResource', + params['Action']) self._test.assertIn('LogicalResourceId', params) - self._test.assertEquals('foo', params['LogicalResourceId']) + self._test.assertEqual('foo', params['LogicalResourceId']) root = etree.Element('DescribeStackResourceResponse') result = etree.SubElement(root, 'DescribeStackResourceResult') detail = etree.SubElement(result, 'StackResourceDetail') @@ -113,9 +113,9 @@ class TestCfn(testtools.TestCase): for k in ('int1', 'strfoo', 'map_ab'): self.assertIn(k, cfn_md) - self.assertEquals(cfn_md[k], META_DATA[k]) + self.assertEqual(cfn_md[k], META_DATA[k]) - self.assertEquals('', self.log.output) + self.assertEqual('', self.log.output) def test_collect_cfn_fail(self): cfn_collect = cfn.Collector(requests_impl=FakeFailRequests) @@ -152,7 +152,7 @@ class TestCfn(testtools.TestCase): content = cfn_collect.collect() self.assertThat(content, matchers.IsInstance(dict)) self.assertIn(u'b', content) - self.assertEquals(u'banana', content[u'b']) + self.assertEqual(u'banana', content[u'b']) def test_collect_cfn_metadata_url_overrides_hint(self): cfg.CONF.cfn.metadata_url = 'http://127.0.1.1:8000/v1/' diff --git a/os_collect_config/tests/test_collect.py b/os_collect_config/tests/test_collect.py index 476f3d5..7af78f7 100644 --- a/os_collect_config/tests/test_collect.py +++ b/os_collect_config/tests/test_collect.py @@ -99,7 +99,7 @@ class TestCollect(testtools.TestCase): config_list = json.loads(list_file.read()) self.assertThat(config_list, matchers.IsInstance(list)) env_config_list = proc_args['env']['OS_CONFIG_FILES'].split(':') - self.assertEquals(env_config_list, config_list) + self.assertEqual(env_config_list, config_list) keys_found = set() for path in env_config_list: self.assertTrue(os.path.exists(path)) @@ -198,7 +198,7 @@ class TestCollect(testtools.TestCase): fixtures.MonkeyPatch('sys.stdout', output.stream)) self._call_main(fake_args) cache_dir = output.getDetails()['stdout'].as_text().strip() - self.assertEquals(fake_cachedir.path, cache_dir) + self.assertEqual(fake_cachedir.path, cache_dir) def test_main_print_only(self): cache_dir = self.useFixture(fixtures.TempDir()) @@ -244,7 +244,7 @@ class TestCollect(testtools.TestCase): pass def fake_sleep(sleep_time): - self.assertEquals(10, sleep_time) + self.assertEqual(10, sleep_time) raise ExpectedException self.useFixture(fixtures.MonkeyPatch('time.sleep', fake_sleep)) @@ -315,7 +315,7 @@ class TestCollectAll(testtools.TestCase): expected_paths = [ os.path.join(self.cache_dir.path, '%s.json' % collector) for collector in new_list] - self.assertEquals(expected_paths, paths) + self.assertEqual(expected_paths, paths) def test_collect_all_nostore(self): (any_changed, content) = self._call_collect_all(store=False) @@ -339,7 +339,7 @@ class TestConf(testtools.TestCase): def test_setup_conf(self): collect.setup_conf() - self.assertEquals('/var/run/os-collect-config', cfg.CONF.cachedir) + self.assertEqual('/var/run/os-collect-config', cfg.CONF.cachedir) self.assertTrue(extras.safe_hasattr(cfg.CONF, 'ec2')) self.assertTrue(extras.safe_hasattr(cfg.CONF, 'cfn')) @@ -351,12 +351,12 @@ class TestHup(testtools.TestCase): self.log = self.useFixture(fixtures.FakeLogger()) def fake_closerange(low, high): - self.assertEquals(3, low) - self.assertEquals(255, high) + self.assertEqual(3, low) + self.assertEqual(255, high) def fake_execv(path, args): - self.assertEquals(sys.argv[0], path) - self.assertEquals(sys.argv, args) + self.assertEqual(sys.argv[0], path) + self.assertEqual(sys.argv, args) self.useFixture(fixtures.MonkeyPatch('os.execv', fake_execv)) self.useFixture(fixtures.MonkeyPatch('os.closerange', fake_closerange)) @@ -387,18 +387,18 @@ class TestFileHash(testtools.TestCase): def test_getfilehash_nofile(self): h = collect.getfilehash([]) - self.assertEquals(h, "d41d8cd98f00b204e9800998ecf8427e") + self.assertEqual(h, "d41d8cd98f00b204e9800998ecf8427e") def test_getfilehash_onefile(self): h = collect.getfilehash([self.file_1]) - self.assertEquals(h, "6f8db599de986fab7a21625b7916589c") + self.assertEqual(h, "6f8db599de986fab7a21625b7916589c") def test_getfilehash_twofiles(self): h = collect.getfilehash([self.file_1, self.file_2]) - self.assertEquals(h, "a8e1b2b743037b1ec17b5d4b49369872") + self.assertEqual(h, "a8e1b2b743037b1ec17b5d4b49369872") def test_getfilehash_filenotfound(self): - self.assertEquals( + self.assertEqual( collect.getfilehash([self.file_1, self.file_2]), collect.getfilehash([self.file_1, "/i/dont/exist", self.file_2]) ) diff --git a/os_collect_config/tests/test_ec2.py b/os_collect_config/tests/test_ec2.py index 87f436a..3060ad8 100644 --- a/os_collect_config/tests/test_ec2.py +++ b/os_collect_config/tests/test_ec2.py @@ -96,15 +96,15 @@ class TestEc2(testtools.TestCase): for k in ('public-ipv4', 'instance-id', 'hostname'): self.assertIn(k, ec2_md) - self.assertEquals(ec2_md[k], META_DATA[k]) + self.assertEqual(ec2_md[k], META_DATA[k]) - self.assertEquals(ec2_md['block-device-mapping']['ami'], 'vda') + self.assertEqual(ec2_md['block-device-mapping']['ami'], 'vda') # SSH keys are special cases - self.assertEquals( + self.assertEqual( {'0': {'openssh-key': 'ssh-rsa AAAAAAAAABBBBBBBBCCCCCCCC'}}, ec2_md['public-keys']) - self.assertEquals('', self.log.output) + self.assertEqual('', self.log.output) def test_collect_ec2_fail(self): collect.setup_conf() diff --git a/os_collect_config/tests/test_heat_local.py b/os_collect_config/tests/test_heat_local.py index 0e2bd98..d0fc3e0 100644 --- a/os_collect_config/tests/test_heat_local.py +++ b/os_collect_config/tests/test_heat_local.py @@ -60,9 +60,9 @@ class TestHeatLocal(testtools.TestCase): for k in ('localstrA', 'localint9', 'localmap_xy'): self.assertIn(k, local_md) - self.assertEquals(local_md[k], META_DATA[k]) + self.assertEqual(local_md[k], META_DATA[k]) - self.assertEquals('', self.log.output) + self.assertEqual('', self.log.output) def test_collect_ec2_nofile(self): tdir = self.useFixture(fixtures.TempDir())