From: Kamalesh Babulal Date: Tue, 15 Feb 2022 07:34:29 +0000 (+0530) Subject: test-044: make it PEP8 compliant X-Git-Tag: v3.1.0~308^2~2^2~61 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=446b42cb778909da3fd101ac214e1bb1b40546f6;p=thirdparty%2Flibcgroup.git test-044: make it PEP8 compliant Make test 044-pybindings-cgcreate_empty_controller.py PEP-8 compliant. Signed-off-by: Kamalesh Babulal Signed-off-by: Tom Hromatka --- diff --git a/ftests/044-pybindings-cgcreate_empty_controller.py b/ftests/044-pybindings-cgcreate_empty_controller.py index 33d594aa..7ac11a5b 100755 --- a/ftests/044-pybindings-cgcreate_empty_controller.py +++ b/ftests/044-pybindings-cgcreate_empty_controller.py @@ -20,34 +20,36 @@ # 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 +from run import Run import consts import ftests -import os -from run import Run import sys +import os CONTROLLER = 'cpu' PARENT_NAME = '044cgcreate' CGNAME = os.path.join(PARENT_NAME, 'madeviapython') + def prereqs(config): result = consts.TEST_PASSED cause = None 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 if CgroupVersion.get_version(CONTROLLER) != CgroupVersion.CGROUP_V2: result = consts.TEST_SKIPPED - cause = "This test requires cgroup v2" + cause = 'This test requires cgroup v2' return result, cause + def setup(config): user_name = Run.run('whoami', shell_bool=True) group_name = Run.run('groups', shell_bool=True).split(' ')[0] @@ -55,6 +57,7 @@ def setup(config): CgroupCli.create(config, controller_list=CONTROLLER, cgname=PARENT_NAME, user_name=user_name, group_name=group_name) + def test(config): result = consts.TEST_PASSED cause = None @@ -64,14 +67,16 @@ def test(config): # Read a valid file within the newly created cgroup. # This should fail if the cgroup was not created successfully - cg.add_setting(setting_name="cgroup.procs") + cg.add_setting(setting_name='cgroup.procs') cg.cgxget() return result, cause + def teardown(config): CgroupCli.delete(config, None, CGNAME) + def main(config): [result, cause] = prereqs(config) if result != consts.TEST_PASSED: @@ -83,6 +88,7 @@ def main(config): return [result, cause] + if __name__ == '__main__': config = ftests.parse_args() # this test was invoked directly. run only it