[Piglit] [PATCH 16/19] results.py: Rename JSONWriter to JSONBackend

Dylan Baker baker.dylan.c at gmail.com
Thu Aug 28 15:35:44 PDT 2014


It's a mostly private class, so renaming it has very little public
effect, and it makes it clearer what the class is.

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 framework/results.py             | 12 ++++++------
 framework/tests/results_tests.py | 10 +++++-----
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/framework/results.py b/framework/results.py
index fcdd154..741adc9 100644
--- a/framework/results.py
+++ b/framework/results.py
@@ -135,7 +135,7 @@ class Backend(object):
         """
 
 
-class JSONWriter(Backend):
+class JSONBackend(Backend):
     '''
     Writes to a JSON file stream
 
@@ -469,7 +469,7 @@ class TestrunResult(object):
         #   5. Return a file object containing the repaired JSON.
 
         # Each non-terminal test result ends with this line:
-        safe_line = 2 * JSONWriter.INDENT * ' ' + '},\n'
+        safe_line = 2 * JSONBackend.INDENT * ' ' + '},\n'
 
         # Search for the last occurence of safe_line.
         safe_line_num = None
@@ -486,10 +486,10 @@ class TestrunResult(object):
         lines = lines[0:(safe_line_num + 1)]
 
         # Remove trailing comma.
-        lines[-1] = 2 * JSONWriter.INDENT * ' ' + '}\n'
+        lines[-1] = 2 * JSONBackend.INDENT * ' ' + '}\n'
 
         # Close json object.
-        lines.append(JSONWriter.INDENT * ' ' + '}\n')
+        lines.append(JSONBackend.INDENT * ' ' + '}\n')
         lines.append('}')
 
         # Return new file object containing the repaired JSON.
@@ -504,7 +504,7 @@ class TestrunResult(object):
         with open(file_, 'w') as f:
             json.dump(dict((k, v) for k, v in self.__dict__.iteritems()
                            if k in self.serialized_keys),
-                      f, default=_piglit_encoder, indent=JSONWriter.INDENT)
+                      f, default=_piglit_encoder, indent=JSONBackend.INDENT)
 
 
 def load_results(filename):
@@ -586,7 +586,7 @@ def update_results(results, filepath):
 def get_backend(backend):
     """ Returns a BackendInstance based on the string passed """
     backends = {
-        'json': JSONWriter,
+        'json': JSONBackend,
     }
 
     # Be sure that we're exporting the same list of backends that we actually
diff --git a/framework/tests/results_tests.py b/framework/tests/results_tests.py
index 9f364fa..f11a86c 100644
--- a/framework/tests/results_tests.py
+++ b/framework/tests/results_tests.py
@@ -61,16 +61,16 @@ def test_generate_initialize():
         yield yieldable, target
 
 
-def test_initialize_jsonwriter():
-    """ Test that JSONWriter initializes
+def test_initialize_jsonbackend():
+    """ Test that JSONBackend initializes
 
     This needs to be handled separately from the others because it requires
     arguments
 
     """
     with utils.tempdir() as tdir:
-        func = results.JSONWriter(tdir, BACKEND_INITIAL_META)
-        assert isinstance(func, results.JSONWriter)
+        func = results.JSONBackend(tdir, BACKEND_INITIAL_META)
+        assert isinstance(func, results.JSONBackend)
 
 
 def test_load_results_folder_as_main():
@@ -173,7 +173,7 @@ def test_get_backend():
     # We use a hand generated list here to ensure that we are getting what we
     # expect
     backends = {
-        'json': results.JSONWriter,
+        'json': results.JSONBackend,
     }
 
     check = lambda n, i: nt.assert_is(results.get_backend(n), i)
-- 
2.1.0



More information about the Piglit mailing list