[Piglit] [PATCH 1/2] framework: Cleanup imports

Dylan Baker baker.dylan.c at gmail.com
Wed Dec 10 11:58:05 PST 2014


Makes 2 changes, all of which should have absolutely zero effect

1) breaks the imports into three newline separated groups: builtins,
installed modules, local modules
2) use print_function and absolute_import in all modules.

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 framework/backends/abstract.py            | 1 +
 framework/backends/json_.py               | 3 +++
 framework/backends/junit.py               | 3 +++
 framework/core.py                         | 3 +--
 framework/dmesg.py                        | 1 +
 framework/log.py                          | 1 +
 framework/profile.py                      | 2 +-
 framework/results.py                      | 2 +-
 framework/status.py                       | 2 ++
 framework/summary.py                      | 3 ++-
 framework/test/__init__.py                | 2 +-
 framework/test/base.py                    | 1 +
 framework/test/gleantest.py               | 1 +
 framework/test/glsl_parser_test.py        | 2 +-
 framework/test/gtest.py                   | 2 ++
 framework/test/oclconform.py              | 3 +--
 framework/test/opencv.py                  | 2 +-
 framework/test/piglit_test.py             | 1 +
 framework/test/shader_test.py             | 1 +
 framework/tests/backends_tests.py         | 3 +++
 framework/tests/base_tests.py             | 2 ++
 framework/tests/core_tests.py             | 4 +++-
 framework/tests/dmesg_tests.py            | 3 +++
 framework/tests/gleantest_tests.py        | 3 ++-
 framework/tests/glsl_parser_test_tests.py | 3 +++
 framework/tests/gtest_tests.py            | 1 +
 framework/tests/integration_tests.py      | 3 +++
 framework/tests/json_tests.py             | 2 +-
 framework/tests/log_tests.py              | 4 +++-
 framework/tests/opencv_tests.py           | 2 ++
 framework/tests/piglit_test_tests.py      | 3 ++-
 framework/tests/profile_tests.py          | 3 +++
 framework/tests/results_tests.py          | 3 +++
 framework/tests/results_v0_tests.py       | 3 +++
 framework/tests/results_v1_tests.py       | 6 +++++-
 framework/tests/run_parser_tests.py       | 3 +++
 framework/tests/shader_test_tests.py      | 3 +++
 framework/tests/status_tests.py           | 3 +++
 framework/tests/summary_tests.py          | 9 +++++++--
 framework/tests/test_lists.py             | 3 +++
 framework/tests/utils.py                  | 3 +++
 41 files changed, 90 insertions(+), 18 deletions(-)

diff --git a/framework/backends/abstract.py b/framework/backends/abstract.py
index 2850297..928ba9a 100644
--- a/framework/backends/abstract.py
+++ b/framework/backends/abstract.py
@@ -25,6 +25,7 @@ This module provides mixins and base classes for backend modules.
 
 """
 
+from __future__ import print_function, absolute_import
 import os
 import abc
 import itertools
diff --git a/framework/backends/json_.py b/framework/backends/json_.py
index 75d00cd..7ba3452 100644
--- a/framework/backends/json_.py
+++ b/framework/backends/json_.py
@@ -20,12 +20,15 @@
 
 """ Module providing json backend for piglit """
 
+from __future__ import print_function, absolute_import
 import os
 import shutil
+
 try:
     import simplejson as json
 except ImportError:
     import json
+
 import framework.status as status
 from .abstract import FileBackend
 
diff --git a/framework/backends/junit.py b/framework/backends/junit.py
index 3647601..6719340 100644
--- a/framework/backends/junit.py
+++ b/framework/backends/junit.py
@@ -20,13 +20,16 @@
 
 """ Module implementing a JUnitBackend for piglit """
 
+from __future__ import print_function, absolute_import
 import os.path
 import re
 import shutil
+
 try:
     from lxml import etree
 except ImportError:
     import xml.etree.cElementTree as etree
+
 from framework.core import PIGLIT_CONFIG
 from .abstract import FileBackend
 
diff --git a/framework/core.py b/framework/core.py
index 9f50c2e..f3022c9 100644
--- a/framework/core.py
+++ b/framework/core.py
@@ -22,13 +22,12 @@
 
 # Piglit core
 
-from __future__ import print_function
+from __future__ import print_function, absolute_import
 import errno
 import os
 import re
 import subprocess
 import sys
-# TODO: ConfigParser is known as configparser in python3
 import ConfigParser
 
 __all__ = [
diff --git a/framework/dmesg.py b/framework/dmesg.py
index 1a8faa2..1a5f629 100644
--- a/framework/dmesg.py
+++ b/framework/dmesg.py
@@ -35,6 +35,7 @@ dmesg implementation for their OS.
 
 """
 
+from __future__ import print_function, absolute_import
 import re
 import sys
 import subprocess
diff --git a/framework/log.py b/framework/log.py
index 819d2f7..759974a 100644
--- a/framework/log.py
+++ b/framework/log.py
@@ -26,6 +26,7 @@ returning BaseLog derived instances to individual tests.
 
 """
 
+from __future__ import print_function, absolute_import
 import sys
 import abc
 import itertools
diff --git a/framework/profile.py b/framework/profile.py
index d3aba73..5e01f20 100644
--- a/framework/profile.py
+++ b/framework/profile.py
@@ -26,7 +26,7 @@ are represented by a TestProfile or a TestProfile derived object.
 
 """
 
-from __future__ import print_function
+from __future__ import print_function, absolute_import
 import os
 import sys
 import multiprocessing
diff --git a/framework/results.py b/framework/results.py
index 6ab22b1..cfc2ec4 100644
--- a/framework/results.py
+++ b/framework/results.py
@@ -21,7 +21,7 @@
 
 """ Module for results generation """
 
-from __future__ import print_function
+from __future__ import print_function, absolute_import
 import os
 import sys
 
diff --git a/framework/status.py b/framework/status.py
index 8ab72f7..9af2ce6 100644
--- a/framework/status.py
+++ b/framework/status.py
@@ -55,6 +55,8 @@ The formula for determining fixes is:
 
 """
 
+from __future__ import print_function, absolute_import
+
 __all__ = ['NOTRUN',
            'PASS',
            'FAIL',
diff --git a/framework/summary.py b/framework/summary.py
index f4fd80d..f5a45fa 100644
--- a/framework/summary.py
+++ b/framework/summary.py
@@ -19,7 +19,7 @@
 # OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 # DEALINGS IN THE SOFTWARE.
  
-from __future__ import print_function
+from __future__ import print_function, absolute_import
 import os
 import os.path as path
 import posixpath
@@ -30,6 +30,7 @@ import tempfile
 import datetime
 import re
 import getpass
+
 from mako.template import Template
 
 # a local variable status exists, prevent accidental overloading by renaming
diff --git a/framework/test/__init__.py b/framework/test/__init__.py
index 9767cbe..a9b5f4e 100644
--- a/framework/test/__init__.py
+++ b/framework/test/__init__.py
@@ -24,7 +24,7 @@
 # create a general use API, but allow it to be controlled by setting the
 # __all__ in each module
 
-from __future__ import absolute_import
+from __future__ import print_function, absolute_import
 from .base import *
 from .piglit_test import *
 from .gleantest import *
diff --git a/framework/test/base.py b/framework/test/base.py
index 7aab45f..851f5f8 100644
--- a/framework/test/base.py
+++ b/framework/test/base.py
@@ -22,6 +22,7 @@
 
 """ Module provides a base class for Tests """
 
+from __future__ import print_function, absolute_import
 import errno
 import os
 import subprocess
diff --git a/framework/test/gleantest.py b/framework/test/gleantest.py
index 6ec285d..de43857 100644
--- a/framework/test/gleantest.py
+++ b/framework/test/gleantest.py
@@ -22,6 +22,7 @@
 
 """ Glean support """
 
+from __future__ import print_function, absolute_import
 import os
 from .base import Test
 from .piglit_test import TEST_BIN_DIR
diff --git a/framework/test/glsl_parser_test.py b/framework/test/glsl_parser_test.py
index 2c48888..6f8ba07 100644
--- a/framework/test/glsl_parser_test.py
+++ b/framework/test/glsl_parser_test.py
@@ -21,7 +21,7 @@
 
 """ This module enables the running of GLSL parser tests. """
 
-from __future__ import print_function
+from __future__ import print_function, absolute_import
 import os
 import os.path as path
 import re
diff --git a/framework/test/gtest.py b/framework/test/gtest.py
index 81dab38..cd80871 100644
--- a/framework/test/gtest.py
+++ b/framework/test/gtest.py
@@ -22,7 +22,9 @@
 # Authors: Tom Stellard <thomas.stellard at amd.com>
 #
 
+from __future__ import print_function, absolute_import 
 import re
+
 from .base import Test
 
 __all__ = [
diff --git a/framework/test/oclconform.py b/framework/test/oclconform.py
index 9d8bcaf..979a52b 100644
--- a/framework/test/oclconform.py
+++ b/framework/test/oclconform.py
@@ -22,8 +22,7 @@
 # Authors: Tom Stellard <thomas.stellard at amd.com>
 #
 
-from __future__ import print_function
-
+from __future__ import print_function, print_function
 import re
 import subprocess
 from os.path import join
diff --git a/framework/test/opencv.py b/framework/test/opencv.py
index 4a8a9a7..baa4a3d 100644
--- a/framework/test/opencv.py
+++ b/framework/test/opencv.py
@@ -22,7 +22,7 @@
 # Authors: Tom Stellard <thomas.stellard at amd.com>
 #
 
-from __future__ import print_function
+from __future__ import print_function, absolute_import
 import re
 import subprocess
 from os import path
diff --git a/framework/test/piglit_test.py b/framework/test/piglit_test.py
index cadd3ed..7511df2 100644
--- a/framework/test/piglit_test.py
+++ b/framework/test/piglit_test.py
@@ -22,6 +22,7 @@
 
 """ Module provides a base class for Tests """
 
+from __future__ import print_function, absolute_import
 import os
 try:
     import simplejson as json
diff --git a/framework/test/shader_test.py b/framework/test/shader_test.py
index fbb0c7f..0d0283c 100644
--- a/framework/test/shader_test.py
+++ b/framework/test/shader_test.py
@@ -23,6 +23,7 @@
 
 """ This module enables running shader tests. """
 
+from __future__ import print_function, absolute_import
 import os
 import os.path as path
 import re
diff --git a/framework/tests/backends_tests.py b/framework/tests/backends_tests.py
index 9050c38..9d76617 100644
--- a/framework/tests/backends_tests.py
+++ b/framework/tests/backends_tests.py
@@ -22,7 +22,9 @@
 
 """ Tests for the backend package """
 
+from __future__ import print_function, absolute_import
 import os
+
 try:
     from lxml import etree
 except ImportError:
@@ -32,6 +34,7 @@ try:
 except ImportError:
     import json
 import nose.tools as nt
+
 import framework.core as core
 import framework.results as results
 import framework.backends as backends
diff --git a/framework/tests/base_tests.py b/framework/tests/base_tests.py
index f8858e4..c22e1ac 100644
--- a/framework/tests/base_tests.py
+++ b/framework/tests/base_tests.py
@@ -20,6 +20,8 @@
 
 """ Tests for the exectest module """
 
+from __future__ import print_function, absolute_import
+
 import nose.tools as nt
 
 import framework.tests.utils as utils
diff --git a/framework/tests/core_tests.py b/framework/tests/core_tests.py
index 7ed3eb1..9c65c31 100644
--- a/framework/tests/core_tests.py
+++ b/framework/tests/core_tests.py
@@ -20,13 +20,15 @@
 
 """ Module providing tests for the core module """
 
-
+from __future__ import print_function, absolute_import
 import os
 import collections
 import shutil
 import ConfigParser
 import textwrap
+
 import nose.tools as nt
+
 import framework.tests.utils as utils
 import framework.core as core
 
diff --git a/framework/tests/dmesg_tests.py b/framework/tests/dmesg_tests.py
index e26f9bb..9a7fef9 100644
--- a/framework/tests/dmesg_tests.py
+++ b/framework/tests/dmesg_tests.py
@@ -25,13 +25,16 @@ don't want to run them use '-e sudo' with nosetests
 
 """
 
+from __future__ import print_function, absolute_import
 import os
 import sys
 import subprocess
 import re
 import json
+
 import nose.tools as nt
 from nose.plugins.skip import SkipTest
+
 import framework.dmesg as dmesg
 import framework.core
 import framework.test
diff --git a/framework/tests/gleantest_tests.py b/framework/tests/gleantest_tests.py
index d0feb24..26872b0 100644
--- a/framework/tests/gleantest_tests.py
+++ b/framework/tests/gleantest_tests.py
@@ -20,7 +20,8 @@
 
 """ Tests for the glean class. Requires Nose """
 
-from __future__ import print_function
+from __future__ import print_function, absolute_import
+
 from framework.test import GleanTest
 
 
diff --git a/framework/tests/glsl_parser_test_tests.py b/framework/tests/glsl_parser_test_tests.py
index 27a9040..37bcc3e 100644
--- a/framework/tests/glsl_parser_test_tests.py
+++ b/framework/tests/glsl_parser_test_tests.py
@@ -20,9 +20,12 @@
 
 """ Provides tests for the shader_test module """
 
+from __future__ import print_function, absolute_import
 import sys
 import os
+
 import nose.tools as nt
+
 import framework.test as glsl
 import framework.tests.utils as utils
 from framework.test import TEST_BIN_DIR
diff --git a/framework/tests/gtest_tests.py b/framework/tests/gtest_tests.py
index 53fe64e..d8c8b64 100644
--- a/framework/tests/gtest_tests.py
+++ b/framework/tests/gtest_tests.py
@@ -20,6 +20,7 @@
 
 """ Module providing tests for gtest """
 
+from __future__ import print_function, absolute_import
 
 from framework.test import GTest
 
diff --git a/framework/tests/integration_tests.py b/framework/tests/integration_tests.py
index c304146..0a157a8 100644
--- a/framework/tests/integration_tests.py
+++ b/framework/tests/integration_tests.py
@@ -26,9 +26,12 @@ errors and to ensure that the API hasn't changed without fixing these modules
 
 """
 
+from __future__ import print_function, absolute_import
 import importlib
 import ConfigParser
+
 from nose.plugins.skip import SkipTest
+
 import framework.core
 
 
diff --git a/framework/tests/json_tests.py b/framework/tests/json_tests.py
index f0daef9..168574f 100644
--- a/framework/tests/json_tests.py
+++ b/framework/tests/json_tests.py
@@ -26,7 +26,7 @@ tests and they will change with each version of the json output.
 
 """
 
-from __future__ import absolute_import
+from __future__ import print_function, absolute_import
 import os
 
 import nose.tools as nt
diff --git a/framework/tests/log_tests.py b/framework/tests/log_tests.py
index 794fcb5..3532b6e 100644
--- a/framework/tests/log_tests.py
+++ b/framework/tests/log_tests.py
@@ -20,10 +20,12 @@
 
 """ Module provides tests for log.py module """
 
-from __future__ import print_function
+from __future__ import print_function, absolute_import
 import sys
 import collections
+
 import nose.tools as nt
+
 import framework.log as log
 import framework.tests.utils as utils
 
diff --git a/framework/tests/opencv_tests.py b/framework/tests/opencv_tests.py
index 5cd89e3..82e0ac5 100644
--- a/framework/tests/opencv_tests.py
+++ b/framework/tests/opencv_tests.py
@@ -20,6 +20,8 @@
 
 """ Module for testing opencv """
 
+from __future__ import print_function, absolute_import
+
 from framework.test import OpenCVTest
 
 
diff --git a/framework/tests/piglit_test_tests.py b/framework/tests/piglit_test_tests.py
index 4dfe855..9834a1b 100644
--- a/framework/tests/piglit_test_tests.py
+++ b/framework/tests/piglit_test_tests.py
@@ -20,9 +20,10 @@
 
 """ Tests for the exectest module """
 
+from __future__ import print_function, absolute_import
+
 import nose.tools as nt
 
-import framework.tests.utils as utils
 from framework.test.piglit_test import (PiglitBaseTest, PiglitGLTest,
                                         PiglitCLTest)
 
diff --git a/framework/tests/profile_tests.py b/framework/tests/profile_tests.py
index c861cfc..0eaf968 100644
--- a/framework/tests/profile_tests.py
+++ b/framework/tests/profile_tests.py
@@ -20,10 +20,13 @@
 
 """ Provides test for the framework.profile modules """
 
+from __future__ import print_function, absolute_import
 import copy
 import platform
+
 import nose.tools as nt
 from nose.plugins.skip import SkipTest
+
 import framework.core as core
 import framework.dmesg as dmesg
 import framework.profile as profile
diff --git a/framework/tests/results_tests.py b/framework/tests/results_tests.py
index 24b8926..6d90990 100644
--- a/framework/tests/results_tests.py
+++ b/framework/tests/results_tests.py
@@ -21,9 +21,12 @@
 """ Module providing tests for the core module """
 
 
+from __future__ import print_function, absolute_import
 import os
 import json
+
 import nose.tools as nt
+
 import framework.tests.utils as utils
 import framework.results as results
 import framework.status as status
diff --git a/framework/tests/results_v0_tests.py b/framework/tests/results_v0_tests.py
index c9ed91e..d5197fd 100644
--- a/framework/tests/results_v0_tests.py
+++ b/framework/tests/results_v0_tests.py
@@ -20,9 +20,12 @@
 
 """ Module provides tests for converting version zero results to version 1 """
 
+from __future__ import print_function, absolute_import
 import json
 import copy
+
 import nose.tools as nt
+
 import framework.results as results
 import framework.tests.utils as utils
 
diff --git a/framework/tests/results_v1_tests.py b/framework/tests/results_v1_tests.py
index bf14231..7ce8b92 100644
--- a/framework/tests/results_v1_tests.py
+++ b/framework/tests/results_v1_tests.py
@@ -20,8 +20,12 @@
 
 """Tests for version 1 to version 2."""
 
-import json
+from __future__ import print_function, absolute_import
 
+try:
+    import simplejson as json
+except ImportError:
+    import json
 import nose.tools as nt
 
 import framework.results as results
diff --git a/framework/tests/run_parser_tests.py b/framework/tests/run_parser_tests.py
index 622e9f7..7e5f466 100644
--- a/framework/tests/run_parser_tests.py
+++ b/framework/tests/run_parser_tests.py
@@ -20,11 +20,14 @@
 
 """ Module of tests for the run commandline parser """
 
+from __future__ import print_function, absolute_import
 import sys
 import os
 import shutil
 import ConfigParser
+
 import nose.tools as nt
+
 import framework.tests.utils as utils
 import framework.programs.run as run
 import framework.core as core
diff --git a/framework/tests/shader_test_tests.py b/framework/tests/shader_test_tests.py
index e627b67..068f32f 100644
--- a/framework/tests/shader_test_tests.py
+++ b/framework/tests/shader_test_tests.py
@@ -20,8 +20,11 @@
 
 """ Provides tests for the shader_test module """
 
+from __future__ import print_function, absolute_import
 import os
+
 import nose.tools as nt
+
 import framework.test as testm
 import framework.tests.utils as utils
 
diff --git a/framework/tests/status_tests.py b/framework/tests/status_tests.py
index 34cbc9c..52ad134 100644
--- a/framework/tests/status_tests.py
+++ b/framework/tests/status_tests.py
@@ -25,8 +25,11 @@ etc
 
 """
 
+from __future__ import print_function, absolute_import
 import itertools
+
 import nose.tools as nt
+
 import framework.status as status
 import framework.tests.utils as utils
 
diff --git a/framework/tests/summary_tests.py b/framework/tests/summary_tests.py
index 61cfbfe..14fa5c2 100644
--- a/framework/tests/summary_tests.py
+++ b/framework/tests/summary_tests.py
@@ -21,10 +21,15 @@
 
 """ Module providing tests for the summary module """
 
-from __future__ import print_function
-import json
+from __future__ import print_function, absolute_import
 import copy
+
+try:
+    import simplejson as json
+except ImportError:
+    import json
 import nose.tools as nt
+
 import framework.summary as summary
 import framework.tests.utils as utils
 
diff --git a/framework/tests/test_lists.py b/framework/tests/test_lists.py
index 5343b44..d56cd2d 100644
--- a/framework/tests/test_lists.py
+++ b/framework/tests/test_lists.py
@@ -26,9 +26,12 @@ es3conform, etc)
 
 """
 
+from __future__ import print_function, absolute_import
 import importlib
 import os.path as path
+
 from nose.plugins.skip import SkipTest
+
 import framework.tests.utils as utils
 
 
diff --git a/framework/tests/utils.py b/framework/tests/utils.py
index f67825f..7546f89 100644
--- a/framework/tests/utils.py
+++ b/framework/tests/utils.py
@@ -25,6 +25,7 @@ in a single place.
 
 """
 
+from __future__ import print_function, absolute_import
 import os
 import sys
 import shutil
@@ -32,12 +33,14 @@ import tempfile
 import functools
 import subprocess
 from contextlib import contextmanager
+
 try:
     import simplejson as json
 except ImportError:
     import json
 from nose.plugins.skip import SkipTest
 import nose.tools as nt
+
 import framework.results
 
 
-- 
2.2.0



More information about the Piglit mailing list