]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
test-004: make it PEP8 complaint
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Wed, 16 Feb 2022 06:19:43 +0000 (11:49 +0530)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 16 Feb 2022 19:09:18 +0000 (12:09 -0700)
Make test 004-cgsnapshot-basic_snapshot_v1.py PEP-8 complaint.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
ftests/004-cgsnapshot-basic_snapshot_v1.py

index 58b32141d967eb2a8e9675ba93d7484faadae374..6eb4911973833556c44586c392c7ec96220f0383 100755 (executable)
 #
 
 from cgroup import Cgroup, CgroupVersion
+from run import RunError
 import consts
 import ftests
-import os
-from run import Run
 import sys
+import os
 
-CONTROLLER='memory'
-CGNAME="004cgsnapshot"
+CONTROLLER = 'memory'
+CGNAME = '004cgsnapshot'
 CGSNAPSHOT = """group 004cgsnapshot {
                     memory {
                             memory.use_hierarchy="1";
@@ -39,7 +39,7 @@ CGSNAPSHOT = """group 004cgsnapshot {
                             memory.max_usage_in_bytes="0";
                             memory.oom_control="oom_kill_disable 0
                                 under_oom 0
-                                oom_kill 0"; 
+                                oom_kill 0";
                             memory.limit_in_bytes="9223372036854771712";
                             memory.swappiness="60";
                             memory.kmem.failcnt="0";
@@ -60,25 +60,28 @@ CGSNAPSHOT_SWAP = """                            memory.memsw.failcnt="0";
 CGSNAPSHOT_NOSWAP = """                    }
             }"""
 
+
 def prereqs(config):
     result = consts.TEST_PASSED
     cause = None
 
     if CgroupVersion.get_version('memory') != CgroupVersion.CGROUP_V1:
         result = consts.TEST_SKIPPED
-        cause = "This test requires the cgroup v1 memory controller"
+        cause = 'This test requires the cgroup v1 memory controller'
         return result, cause
 
     if not config.args.container:
         result = consts.TEST_SKIPPED
-        cause = "This test must be run within a container"
+        cause = 'This test must be run within a container'
         return result, cause
 
     return result, cause
 
+
 def setup(config):
     Cgroup.create(config, CONTROLLER, CGNAME)
 
+
 def test(config):
     result = consts.TEST_PASSED
     cause = None
@@ -86,9 +89,9 @@ def test(config):
     try:
         # check if the memsw.failcnt file exists.  if so, add it to the
         # expected snapshot
-        Cgroup.get(config, setting="memory.memsw.failcnt", cgname=CGNAME)
+        Cgroup.get(config, setting='memory.memsw.failcnt', cgname=CGNAME)
         expected_str = CGSNAPSHOT + CGSNAPSHOT_SWAP
-    except:
+    except RunError:
         # memsw files don't exist.  exclude them from the snapshot
         expected_str = CGSNAPSHOT + CGSNAPSHOT_NOSWAP
 
@@ -97,13 +100,15 @@ def test(config):
 
     if expected[CGNAME] != actual[CGNAME]:
         result = consts.TEST_FAILED
-        cause = "Expected cgsnapshot result did not equal actual cgsnapshot"
+        cause = 'Expected cgsnapshot result did not equal actual cgsnapshot'
 
     return result, cause
 
+
 def teardown(config):
     Cgroup.delete(config, CONTROLLER, CGNAME)
 
+
 def main(config):
     [result, cause] = prereqs(config)
     if result != consts.TEST_PASSED:
@@ -115,6 +120,7 @@ def main(config):
 
     return [result, cause]
 
+
 if __name__ == '__main__':
     config = ftests.parse_args()
     # this test was invoked directly.  run only it