From: Kamalesh Babulal Date: Tue, 15 Feb 2022 07:03:28 +0000 (+0530) Subject: test-014: make it PEP8 compliant X-Git-Tag: v3.1.0~308^2~2^2~89 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=97e345f6d1f087e69071ce206628cae6ee44df7c;p=thirdparty%2Flibcgroup.git test-014: make it PEP8 compliant Make test 014-cgget-a_flag.py PEP-8 compliant. Signed-off-by: Kamalesh Babulal Signed-off-by: Tom Hromatka --- diff --git a/ftests/014-cgget-a_flag.py b/ftests/014-cgget-a_flag.py index 102d440d..1dab5549 100755 --- a/ftests/014-cgget-a_flag.py +++ b/ftests/014-cgget-a_flag.py @@ -23,12 +23,13 @@ from cgroup import Cgroup, CgroupVersion import consts import ftests -import os import sys +import os + +CONTROLLER1 = 'memory' +CONTROLLER2 = 'cpuset' +CGNAME = '014cgget' -CONTROLLER1='memory' -CONTROLLER2='cpuset' -CGNAME="014cgget" def prereqs(config): result = consts.TEST_PASSED @@ -36,6 +37,7 @@ def prereqs(config): return result, cause + def setup(config): ver1 = CgroupVersion.get_version(CONTROLLER1) ver2 = CgroupVersion.get_version(CONTROLLER2) @@ -49,6 +51,7 @@ def setup(config): Cgroup.create(config, CONTROLLER1, CGNAME) Cgroup.create(config, CONTROLLER2, CGNAME) + def test(config): result = consts.TEST_PASSED cause = None @@ -58,25 +61,28 @@ def test(config): # arbitrary check to ensure we read several lines if len(out.splitlines()) < 20: result = consts.TEST_FAILED - cause = "Expected multiple lines, but only received {}".format( - len(out.splitlines())) + cause = ( + 'Expected multiple lines, but only received {}' + ''.format(len(out.splitlines())) + ) return result, cause # arbitrary check for a setting that's in both cgroup v1 and cgroup v2 # memory.stat - if not "\tpgmajfault" in out: + if '\tpgmajfault' not in out: result = consts.TEST_FAILED - cause = "Unexpected output\n{}".format(out) + cause = 'Unexpected output\n{}'.format(out) return result, cause # make sure that a cpuset value was in the output: - if not "cpuset.cpus" in out: + if 'cpuset.cpus' not in out: result = consts.TEST_FAILED - cause = "Failed to find cpuset settings in output\n{}".format(out) + cause = 'Failed to find cpuset settings in output\n{}'.format(out) return result, cause return result, cause + def teardown(config): ver1 = CgroupVersion.get_version(CONTROLLER1) ver2 = CgroupVersion.get_version(CONTROLLER2) @@ -90,6 +96,7 @@ def teardown(config): Cgroup.delete(config, CONTROLLER1, CGNAME) Cgroup.delete(config, CONTROLLER2, CGNAME) + def main(config): [result, cause] = prereqs(config) if result != consts.TEST_PASSED: @@ -101,6 +108,7 @@ def main(config): return [result, cause] + if __name__ == '__main__': config = ftests.parse_args() # this test was invoked directly. run only it