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

Dylan Baker baker.dylan.c at gmail.com
Wed Jan 28 11:35:04 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 | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/tests/igt.py b/tests/igt.py
index bba7b5a..3e620a6 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!"
@@ -78,10 +78,10 @@ if not (os.path.exists(os.path.join(IGT_TEST_ROOT, 'single-tests.txt'))
 class IGTTestProfile(TestProfile):
     """ Test profile for intel-gpu-tools tests. """
     def _pre_run_hook(self):
-        if not checkEnvironment():
+        if not check_environment():
             sys.exit(1)
 
-profile = IGTTestProfile()
+profile = TestProfile()  # pylint: disable=invalid-name
 
 class IGTTest(Test):
     def __init__(self, binary, arguments=None):
@@ -102,7 +102,7 @@ class IGTTest(Test):
             self.result['result'] = 'fail'
 
 
-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())
 
@@ -117,10 +117,7 @@ def listTests(listname):
 
     return []
 
-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,
@@ -145,9 +142,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