From 4713692aa4639966ac4a53a1fb097f93e4da9139 Mon Sep 17 00:00:00 2001 From: Kyr Shatskyy Date: Mon, 18 Nov 2019 17:58:04 +0100 Subject: [PATCH] get dict's keys as list in py3 compatible way Signed-off-by: Kyr Shatskyy --- teuthology/task/internal/__init__.py | 7 ++++--- teuthology/test/task/__init__.py | 10 +++++----- teuthology/test/task/test_selinux.py | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/teuthology/task/internal/__init__.py b/teuthology/task/internal/__init__.py index 80832cbf6b..5f00653b44 100644 --- a/teuthology/task/internal/__init__.py +++ b/teuthology/task/internal/__init__.py @@ -206,11 +206,12 @@ def buildpackages_prep(ctx, config): buildpackages_index = None buildpackages_prep_index = None for task in ctx.config['tasks']: - if task.keys()[0] == 'install': + t = list(task)[0] + if t == 'install': install_index = index - if task.keys()[0] == 'buildpackages': + if t == 'buildpackages': buildpackages_index = index - if task.keys()[0] == 'internal.buildpackages_prep': + if t == 'internal.buildpackages_prep': buildpackages_prep_index = index index += 1 if (buildpackages_index is not None and diff --git a/teuthology/test/task/__init__.py b/teuthology/test/task/__init__.py index f03737e8cf..6fae57a810 100644 --- a/teuthology/test/task/__init__.py +++ b/teuthology/test/task/__init__.py @@ -44,7 +44,7 @@ class TestTask(object): end=DEFAULT, ): with self.klass(self.ctx, self.task_config) as task: - task_hosts = task.cluster.remotes.keys() + task_hosts = list(task.cluster.remotes) assert len(task_hosts) == 2 assert sorted(host.shortname for host in task_hosts) == \ ['remote1', 'remote2'] @@ -77,7 +77,7 @@ class TestTask(object): end=DEFAULT, ): with self.klass(self.ctx, self.task_config) as task: - task_hosts = task.cluster.remotes.keys() + task_hosts = list(task.cluster.remotes) assert len(task_hosts) == 1 assert task_hosts[0].shortname == 'remote1' @@ -95,7 +95,7 @@ class TestTask(object): end=DEFAULT, ): with self.klass(self.ctx, self.task_config) as task: - task_hosts = task.cluster.remotes.keys() + task_hosts = list(task.cluster.remotes) assert len(task_hosts) == 2 hostnames = [host.shortname for host in task_hosts] assert sorted(hostnames) == ['remote1', 'remote3'] @@ -114,7 +114,7 @@ class TestTask(object): end=DEFAULT, ): with self.klass(self.ctx, self.task_config) as task: - task_hosts = task.cluster.remotes.keys() + task_hosts = list(task.cluster.remotes) assert len(task_hosts) == 2 hostnames = [host.hostname for host in task_hosts] assert sorted(hostnames) == ['remote1.example.com', @@ -134,7 +134,7 @@ class TestTask(object): end=DEFAULT, ): with self.klass(self.ctx, self.task_config) as task: - task_hosts = task.cluster.remotes.keys() + task_hosts = list(task.cluster.remotes) assert len(task_hosts) == 2 hostnames = [host.hostname for host in task_hosts] assert sorted(hostnames) == ['remote1.example.com', diff --git a/teuthology/test/task/test_selinux.py b/teuthology/test/task/test_selinux.py index e12e81c0a9..ddbff06d08 100644 --- a/teuthology/test/task/test_selinux.py +++ b/teuthology/test/task/test_selinux.py @@ -30,6 +30,6 @@ class TestSELinux(object): self.ctx.cluster.add(remote2, ['role2']) task_config = dict() with SELinux(self.ctx, task_config) as task: - remotes = task.cluster.remotes.keys() + remotes = list(task.cluster.remotes) assert remotes == [remote1] -- 2.39.5