From 93268fac13d9dcf88b77e9ae6a3ba9828fad924e Mon Sep 17 00:00:00 2001 From: Tom Hromatka Date: Mon, 1 Mar 2021 16:37:38 +0000 Subject: [PATCH] ftests: Clean up a few exceptions In the ftests and process files, two exceptions were erroneously throwing ValueException rather than ValueError. Fix this. In CgroupVersion.get_version(), it returned CGROUP_UNK if it couldn't determine the version. Make this method more pythonic by raising a ValueError exception. Signed-off-by: Tom Hromatka --- ftests/cgroup.py | 2 +- ftests/ftests.py | 2 +- ftests/process.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ftests/cgroup.py b/ftests/cgroup.py index b32bbbf0..a5ceeb55 100644 --- a/ftests/cgroup.py +++ b/ftests/cgroup.py @@ -51,7 +51,7 @@ class CgroupVersion(Enum): if ctrl == controller: return CgroupVersion.CGROUP_V2 - return CgroupVersion.CGROUP_UNK + raise IndexError("Unknown version for controller {}".format(controller)) class Cgroup(object): # This class is analogous to libcgroup's struct cgroup diff --git a/ftests/ftests.py b/ftests/ftests.py index e2efb7b5..db18dc99 100755 --- a/ftests/ftests.py +++ b/ftests/ftests.py @@ -234,7 +234,7 @@ def run_tests(config): elif ret == consts.TEST_SKIPPED: skipped_tests.append([filename, run_time, failure_cause]) else: - raise ValueException('Unexpected ret: {}'.format(ret)) + raise ValueError('Unexpected ret: {}'.format(ret)) passed_cnt = len(passed_tests) failed_cnt = len(failed_tests) diff --git a/ftests/process.py b/ftests/process.py index 9fa456e8..cfc4ccdc 100644 --- a/ftests/process.py +++ b/ftests/process.py @@ -81,7 +81,7 @@ class Process(object): pid = pid.splitlines()[1] if pid == "" or int(pid) <= 0: - raise ValueException('Failed to get the pid of the child process: {}'.format(pid)) + raise ValueError('Failed to get the pid of the child process: {}'.format(pid)) self.children.append(p) return pid -- 2.47.2