From: Tom Hromatka Date: Mon, 1 Mar 2021 16:37:38 +0000 (+0000) Subject: ftests: Clean up a few exceptions X-Git-Tag: v2.0.3~11^2^2~25^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=93268fac13d9dcf88b77e9ae6a3ba9828fad924e;p=thirdparty%2Flibcgroup.git 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 --- 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