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

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
ftests/020-cgconfig-tasks_perms_owner.py

index c82cf05a4509c50474b9c862bf6bfcc3724d419c..673e2bc4bfc5e23968b9c76f1aed529fd1e88120 100755 (executable)
 #
 
 from cgroup import Cgroup, CgroupVersion
+from container import ContainerError
+from run import Run, RunError
 import consts
 import ftests
-import os
-from run import Run
-import sys
 import utils
+import sys
+import os
 
 CONTROLLER = 'cpuset'
 CGNAME = '020cgconfig'
@@ -43,17 +44,19 @@ TPERM = '642'
 
 CONFIG_FILE_NAME = os.path.join(os.getcwd(), '020cgconfig.conf')
 
+
 def prereqs(config):
     result = consts.TEST_PASSED
     cause = None
 
     if CgroupVersion.get_version('cpuset') != CgroupVersion.CGROUP_V1:
         result = consts.TEST_SKIPPED
-        cause = "This test requires the cgroup v1 cpuset controller"
+        cause = 'This test requires the cgroup v1 cpuset controller'
         return result, cause
 
     return result, cause
 
+
 def setup(config):
     f = open(CONFIG_FILE_NAME, 'w')
     f.write(CONFIG_FILE)
@@ -66,6 +69,7 @@ def setup(config):
         Run.run(['sudo', 'useradd', '-p', 'Test020#1', USER])
         Run.run(['sudo', 'groupadd', GROUP])
 
+
 def test(config):
     result = consts.TEST_PASSED
     cause = None
@@ -81,25 +85,32 @@ def test(config):
 
     if user != USER:
         result = consts.TEST_FAILED
-        cause = "Owner name failed.  Expected {}, received {}\n".format(
-                USER, user)
+        cause = (
+                    'Owner name failed.  Expected {}, received {}\n'
+                    ''.format(USER, user)
+                )
         return result, cause
 
     if group != GROUP:
         result = consts.TEST_FAILED
-        cause = "Owner group failed.  Expected {}, received {}\n".format(
-                GROUP, group)
+        cause = (
+                    'Owner group failed.  Expected {}, received {}\n'
+                    ''.format(GROUP, group)
+                )
         return result, cause
 
     tperm = utils.get_file_permissions(config, tasks_path)
     if tperm != TPERM:
         result = consts.TEST_FAILED
-        cause = "File permissions failed.  Expected {}, received {}\n".format(
-                TPERM, tperm)
+        cause = (
+                    'File permissions failed.  Expected {}, received {}\n'
+                    ''.format(TPERM, tperm)
+                )
         return result, cause
 
     return result, cause
 
+
 def teardown(config):
     os.remove(CONFIG_FILE_NAME)
 
@@ -110,11 +121,12 @@ def teardown(config):
         else:
             Run.run(['sudo', 'userdel', USER])
             Run.run(['sudo', 'groupdel', GROUP])
-    except:
+    except (ContainerError, RunError, ValueError):
         pass
 
     Cgroup.delete(config, CONTROLLER, CGNAME)
 
+
 def main(config):
     [result, cause] = prereqs(config)
     if result != consts.TEST_PASSED:
@@ -128,6 +140,7 @@ def main(config):
 
     return [result, cause]
 
+
 if __name__ == '__main__':
     config = ftests.parse_args()
     # this test was invoked directly.  run only it