]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
test-039: make it PEP8 compliant
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Tue, 15 Feb 2022 07:32:12 +0000 (13:02 +0530)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 16 Feb 2022 19:09:18 +0000 (12:09 -0700)
Make test 039-pybindings-cgxget.py PEP-8 compliant.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
ftests/039-pybindings-cgxget.py

index ff6f72561946f4f3adc21af5878451dcd1c9df37..8e24d21cfb45f56986b58c6cd3e1812f98865c71 100755 (executable)
 # along with this library; if not, see <http://www.gnu.org/licenses>.
 #
 
-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