[Piglit] [PATCH 09/11] profile.py: stop exposing private methods of TestProfile

Dylan Baker baker.dylan.c at gmail.com
Fri Apr 25 13:27:41 PDT 2014


This patch stops exposing flatten_group_hierarchy and prepare_test_list
by marking them with a leading underscore. These methods weren't meant
to be called outside, and this is the pythonic way of letting users know
that these are "private" methods.
---
 framework/profile.py             | 16 ++++++++--------
 framework/tests/profile_tests.py | 14 +++++++-------
 tests/xts.py                     |  2 +-
 3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/framework/profile.py b/framework/profile.py
index 7decef0..db6fb45 100644
--- a/framework/profile.py
+++ b/framework/profile.py
@@ -82,7 +82,7 @@ class TestProfile(object):
         """
         self._dmesg = get_dmesg(not_dummy)
 
-    def flatten_group_hierarchy(self):
+    def _flatten_group_hierarchy(self):
         """ Flatten nested dictionary structure
 
         Convert Piglit's old hierarchical Group() structure into a flat
@@ -107,7 +107,7 @@ class TestProfile(object):
         # Clear out the old Group()
         self.tests = {}
 
-    def prepare_test_list(self, env):
+    def _prepare_test_list(self, env):
         """ Prepare tests for running
 
         Flattens the nested group hierarchy into a flat dictionary using '/'
@@ -118,7 +118,7 @@ class TestProfile(object):
         env - a core.Environment instance
 
         """
-        self.flatten_group_hierarchy()
+        self._flatten_group_hierarchy()
 
         def matches_any_regexp(x, re_list):
             return any(r.search(x) for r in re_list)
@@ -143,7 +143,7 @@ class TestProfile(object):
         self.test_list = dict(item for item in self.test_list.iteritems()
                               if check_all(item))
 
-    def pre_run_hook(self):
+    def _pre_run_hook(self):
         """ Hook executed at the start of TestProfile.run
 
         To make use of this hook one will need to subclass TestProfile, and
@@ -152,7 +152,7 @@ class TestProfile(object):
         """
         pass
 
-    def post_run_hook(self):
+    def _post_run_hook(self):
         """ Hook executed at the end of TestProfile.run
 
         To make use of this hook one will need to subclass TestProfile, and
@@ -180,12 +180,12 @@ class TestProfile(object):
 
         """
 
-        self.pre_run_hook()
+        self._pre_run_hook()
         framework.exectest.Test.ENV = env
 
         chunksize = 1
 
-        self.prepare_test_list(env)
+        self._prepare_test_list(env)
         log = Log(len(self.test_list), env.verbose)
 
         def test(pair):
@@ -224,7 +224,7 @@ class TestProfile(object):
 
         log.summary()
 
-        self.post_run_hook()
+        self._post_run_hook()
 
     def filter_tests(self, function):
         """Filter out tests that return false from the supplied function
diff --git a/framework/tests/profile_tests.py b/framework/tests/profile_tests.py
index 9119dbd..94354ad 100644
--- a/framework/tests/profile_tests.py
+++ b/framework/tests/profile_tests.py
@@ -87,7 +87,7 @@ def test_testprofile_flatten():
     profile_.tests['group1']['group2']['test2'] = 'thing'
     profile_.tests['group1']['group2']['group3']['test3'] = 'thing'
 
-    profile_.flatten_group_hierarchy()
+    profile_._flatten_group_hierarchy()
 
     baseline = {
         'group1/test1': 'thing',
@@ -160,7 +160,7 @@ def check_flatten(tests, testlist):
     """ TestProfile.prepare_test_list flattens TestProfile.tests """
     profile_ = profile.TestProfile()
     profile_.tests = tests
-    profile_.flatten_group_hierarchy()
+    profile_._flatten_group_hierarchy()
 
     nt.assert_dict_equal(profile_.test_list, testlist)
 
@@ -171,7 +171,7 @@ def check_mixed_flatten(tests, testlist):
     profile_ = profile.TestProfile()
     profile_.tests = tests
     profile_.test_list['test8'] = 'other'
-    profile_.flatten_group_hierarchy()
+    profile_._flatten_group_hierarchy()
 
     baseline = {'test8': 'other'}
     baseline.update(testlist)
@@ -215,7 +215,7 @@ def test_matches_filter_mar_1(data):
 
     profile_ = profile.TestProfile()
     profile_.test_list = data
-    profile_.prepare_test_list(env)
+    profile_._prepare_test_list(env)
 
     nt.assert_dict_equal(profile_.test_list, data)
 
@@ -227,7 +227,7 @@ def test_matches_filter_mar_2(data):
 
     profile_ = profile.TestProfile()
     profile_.test_list = data
-    profile_.prepare_test_list(env)
+    profile_._prepare_test_list(env)
 
     baseline = {'group3/test5': 'other'}
 
@@ -242,7 +242,7 @@ def test_matches_env_exclude(data):
 
     profile_ = profile.TestProfile()
     profile_.test_list = data
-    profile_.prepare_test_list(env)
+    profile_._prepare_test_list(env)
 
     baseline = copy.deepcopy(data)
     del baseline['group3/test5']
@@ -257,7 +257,7 @@ def test_matches_exclude_mar(data):
 
     profile_ = profile.TestProfile()
     profile_.test_list = data
-    profile_.prepare_test_list(env)
+    profile_._prepare_test_list(env)
 
     baseline = copy.deepcopy(data)
     del baseline['group3/test5']
diff --git a/tests/xts.py b/tests/xts.py
index c9710fa..efed504 100644
--- a/tests/xts.py
+++ b/tests/xts.py
@@ -38,7 +38,7 @@ X_TEST_SUITE = os.path.join(TEST_BIN_DIR, 'xtest')
 
 class XTSProfile(TestProfile):
     """ A subclass of TestProfile that provides a setup hook for XTS """
-    def pre_run_hook(self):
+    def _pre_run_hook(self):
         """ This hook sets the XTSTest.results_path variable
 
         Setting this variable allows images created by XTS to moved into the
-- 
2.0.0.rc0



More information about the Piglit mailing list