From 01867018c1089f83d2b3bd5371e722a0fb67cb96 Mon Sep 17 00:00:00 2001 From: Owen Tuz Date: Wed, 18 Nov 2020 13:08:02 +0000 Subject: [PATCH 1/2] Allow Python versions greater than 3.3 for inventory-builder tests Python 3.3 is deprecated and produces warnings. This change relaxes the requirement to allow any version of Python 3. --- contrib/inventory_builder/tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/inventory_builder/tox.ini b/contrib/inventory_builder/tox.ini index 889fe78537f..125f6463e33 100644 --- a/contrib/inventory_builder/tox.ini +++ b/contrib/inventory_builder/tox.ini @@ -1,7 +1,7 @@ [tox] minversion = 1.6 skipsdist = True -envlist = pep8, py33 +envlist = pep8, py3 [testenv] whitelist_externals = py.test From b319a9198a405054a7c4e67b1eb95eef807cc39e Mon Sep 17 00:00:00 2001 From: Owen Tuz Date: Wed, 18 Nov 2020 13:12:21 +0000 Subject: [PATCH 2/2] Fix PEP8 problems (AssertTrue vs AssertIn) --- .../inventory_builder/tests/test_inventory.py | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/contrib/inventory_builder/tests/test_inventory.py b/contrib/inventory_builder/tests/test_inventory.py index aa03e7c6409..1172406ea94 100644 --- a/contrib/inventory_builder/tests/test_inventory.py +++ b/contrib/inventory_builder/tests/test_inventory.py @@ -51,7 +51,7 @@ def test_ensure_required_groups(self): groups = ['group1', 'group2'] self.inv.ensure_required_groups(groups) for group in groups: - self.assertTrue(group in self.inv.yaml_config['all']['children']) + self.assertIn(group, self.inv.yaml_config['all']['children']) def test_get_host_id(self): hostnames = ['node99', 'no99de01', '01node01', 'node1.domain', @@ -227,8 +227,9 @@ def test_set_kube_master(self): host = 'node1' self.inv.set_kube_master([host]) - self.assertTrue( - host in self.inv.yaml_config['all']['children'][group]['hosts']) + self.assertIn( + host, + self.inv.yaml_config['all']['children'][group]['hosts']) def test_set_all(self): hosts = OrderedDict([ @@ -246,8 +247,8 @@ def test_set_k8s_cluster(self): self.inv.set_k8s_cluster() for host in expected_hosts: - self.assertTrue( - host in + self.assertIn( + host, self.inv.yaml_config['all']['children'][group]['children']) def test_set_kube_node(self): @@ -255,16 +256,18 @@ def test_set_kube_node(self): host = 'node1' self.inv.set_kube_node([host]) - self.assertTrue( - host in self.inv.yaml_config['all']['children'][group]['hosts']) + self.assertIn( + host, + self.inv.yaml_config['all']['children'][group]['hosts']) def test_set_etcd(self): group = 'etcd' host = 'node1' self.inv.set_etcd([host]) - self.assertTrue( - host in self.inv.yaml_config['all']['children'][group]['hosts']) + self.assertIn( + host, + self.inv.yaml_config['all']['children'][group]['hosts']) def test_scale_scenario_one(self): num_nodes = 50