From: Kamalesh Babulal Date: Tue, 15 Feb 2022 07:32:12 +0000 (+0530) Subject: test-039: make it PEP8 compliant X-Git-Tag: v3.1.0~308^2~2^2~66 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=65af11af8b26d4a30480f77a31b230e2e8e9c4e6;p=thirdparty%2Flibcgroup.git test-039: make it PEP8 compliant Make test 039-pybindings-cgxget.py PEP-8 compliant. Signed-off-by: Kamalesh Babulal Signed-off-by: Tom Hromatka --- diff --git a/ftests/039-pybindings-cgxget.py b/ftests/039-pybindings-cgxget.py index ff6f7256..8e24d21c 100755 --- a/ftests/039-pybindings-cgxget.py +++ b/ftests/039-pybindings-cgxget.py @@ -20,16 +20,16 @@ # along with this library; if not, see . # -from cgroup import CgroupVersion from cgroup import Cgroup as CgroupCli from libcgroup import Cgroup, Version +from cgroup import CgroupVersion import consts import ftests -import os import sys +import os CONTROLLER = 'cpu' -CGNAME = "039bindings" +CGNAME = '039bindings' SETTING1 = 'cpu.shares' VALUE1 = '4096' @@ -37,10 +37,11 @@ VALUE1 = '4096' SETTING2 = 'cpu.weight' VALUE2 = '400' + def prereqs(config): if config.args.container: result = consts.TEST_SKIPPED - cause = "This test cannot be run within a container" + cause = 'This test cannot be run within a container' return result, cause result = consts.TEST_PASSED @@ -48,6 +49,7 @@ def prereqs(config): return result, cause + def setup(config): CgroupCli.create(config, CONTROLLER, CGNAME) if CgroupVersion.get_version('cpu') == CgroupVersion.CGROUP_V1: @@ -55,6 +57,7 @@ def setup(config): else: CgroupCli.set(config, CGNAME, SETTING2, VALUE2) + def test(config): result = consts.TEST_PASSED cause = None @@ -67,20 +70,29 @@ def test(config): if len(cg1.controllers) != 1: result = consts.TEST_FAILED - cause = "Controller length doesn't match, expected 1, but received {}".format( - len(cg1.controllers)) + cause = ( + "Controller length doesn't match, expected 1, but " + "received {}" + "".format(len(cg1.controllers)) + ) return result, cause if len(cg1.controllers[CONTROLLER].settings) != 1: result = consts.TEST_FAILED - cause = "Settings length doesn't match, expected 1, but received {}".format( - len(cg1.controllers[CONTROLLER].settings)) + cause = ( + "Settings length doesn't match, expected 1, but " + " received {}" + "".format(len(cg1.controllers[CONTROLLER].settings)) + ) return result, cause if cg1.controllers[CONTROLLER].settings[SETTING1] != VALUE1: result = consts.TEST_FAILED - cause = "Expected {} = {} but received {}".format(SETTING1, VALUE1, - cg1.controllers[CONTROLLER].settings[SETTING1]) + cause = ( + 'Expected {} = {} but received {}' + ''.format(SETTING1, VALUE1, + cg1.controllers[CONTROLLER].settings[SETTING1]) + ) return result, cause cg2 = Cgroup(CGNAME, Version.CGROUP_V2) @@ -91,27 +103,38 @@ def test(config): if len(cg2.controllers) != 1: result = consts.TEST_FAILED - cause = "Controller length doesn't match, expected 1, but received {}".format( - len(cg2.controllers)) + cause = ( + "Controller length doesn't match, expected 1, but" + " received {}" + "".format(len(cg2.controllers)) + ) return result, cause if len(cg2.controllers[CONTROLLER].settings) != 1: result = consts.TEST_FAILED - cause = "Settings length doesn't match, expected 1, but received {}".format( - len(cg2.controllers[CONTROLLER].settings)) + cause = ( + "Settings length doesn't match, expected 1, but" + "received {}" + "".format(len(cg2.controllers[CONTROLLER].settings)) + ) return result, cause if cg2.controllers[CONTROLLER].settings[SETTING2] != VALUE2: result = consts.TEST_FAILED - cause = "Expected {} = {} but received {}".format(SETTING2, VALUE2, - cg2.controllers[CONTROLLER].settings[SETTING2]) + cause = ( + 'Expected {} = {} but received {}' + ''.format(SETTING2, VALUE2, + cg2.controllers[CONTROLLER].settings[SETTING2]) + ) return result, cause return result, cause + def teardown(config): CgroupCli.delete(config, CONTROLLER, CGNAME) + def main(config): [result, cause] = prereqs(config) if result != consts.TEST_PASSED: @@ -123,6 +146,7 @@ def main(config): return [result, cause] + if __name__ == '__main__': config = ftests.parse_args() # this test was invoked directly. run only it