[Piglit] [Patch v2 4/8] igt.py: fix invalid name errors

Dylan Baker baker.dylan.c at gmail.com
Mon Jan 26 11:28:11 PST 2015


Make constants all caps, per PEP8, make functions all lowercase with
underscores, and move some toplevel work into helper functions.

v2: - drop one pylint disable line that wasn't needed (Thomas)

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 tests/igt.py | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/tests/igt.py b/tests/igt.py
index 482c7e1..fe2364c 100644
--- a/tests/igt.py
+++ b/tests/igt.py
@@ -41,7 +41,7 @@ __all__ = ['profile']
 ##### automatically add all tests into the 'igt' category.
 #############################################################################
 
-def checkEnvironment():
+def check_environment():
     debugfs_path = "/sys/kernel/debug/dri"
     if os.getuid() != 0:
         print "Test Environment check: not root!"
@@ -74,9 +74,9 @@ if not (os.path.exists(os.path.join(IGT_TEST_ROOT, 'single-tests.txt'))
     print "intel-gpu-tools test lists not found."
     sys.exit(0)
 
-igtEnvironmentOk = checkEnvironment()
+IGT_ENVIRONMENT_OK = check_environment()
 
-profile = TestProfile()
+profile = TestProfile()  # pylint: disable=invalid-name
 
 class IGTTest(Test):
     def __init__(self, binary, arguments=None):
@@ -87,7 +87,7 @@ class IGTTest(Test):
         self.timeout = 600
 
     def interpret_result(self):
-        if not igtEnvironmentOk:
+        if not IGT_ENVIRONMENT_OK:
             return
 
         if self.result['returncode'] == 0:
@@ -100,14 +100,14 @@ class IGTTest(Test):
             self.result['result'] = 'fail'
 
     def run(self):
-        if not igtEnvironmentOk:
+        if not IGT_ENVIRONMENT_OK:
             self.result['result'] = 'fail'
             self.result['info'] = unicode("Test Environment isn't OK")
             return
 
         super(IGTTest, self).run()
 
-def listTests(listname):
+def list_tests(listname):
     with open(os.path.join(IGT_TEST_ROOT, listname + '.txt'), 'r') as f:
         lines = (line.rstrip() for line in f.readlines())
 
@@ -124,10 +124,7 @@ def listTests(listname):
 
     return progs
 
-tests = listTests("single-tests")
-tests.extend(listTests("multi-tests"))
-
-def addSubTestCases(test):
+def add_subtest_cases(test):
     proc = subprocess.Popen(
         [os.path.join(IGT_TEST_ROOT, test), '--list-subtests'],
         stdout=subprocess.PIPE,
@@ -152,9 +149,16 @@ def addSubTestCases(test):
         profile.test_list[grouptools.join('igt', test, subtest)] = \
             IGTTest(test, ['--run-subtest', subtest])
 
-for test in tests:
-    addSubTestCases(test)
 
+def populate_profile():
+    tests = list_tests("single-tests")
+    tests.extend(list_tests("multi-tests"))
+
+    for test in tests:
+        add_subtest_cases(test)
+
+
+populate_profile()
 profile.dmesg = True
 
 # the dmesg property of TestProfile returns a Dmesg object
-- 
2.2.2



More information about the Piglit mailing list