[Piglit] [PATCH 02/44] python: use future print, division, and absolute_import

baker.dylan.c at gmail.com baker.dylan.c at gmail.com
Wed Jan 27 16:06:10 PST 2016


From: Dylan Baker <baker.dylan.c at gmail.com>

These are the three python3 like behaviors that piglit should rely on.
The only other applicable future import is unicode_literals. Although my
plan is to use unicode_literals, that will actually cause behavioral
changes in some cases, where these cause minimal changes to the code.

Piglit will not be targeting < 3.2, they are old, unsupported, and have
fewer features than 2.7.

Piglit now has division (using / as floating division, and // as integer
division), print as a function (rather than a statement), and
absolute import, which changes the way import works when there's a
conflict between a local import and a system wide one. Absolute import
makes more sense, and copies the behavior of python 3

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 framework/backends/__init__.py      | 1 +
 framework/backends/abstract.py      | 2 +-
 framework/backends/json.py          | 2 +-
 framework/backends/junit.py         | 2 +-
 framework/backends/register.py      | 1 +
 framework/core.py                   | 2 +-
 framework/grouptools.py             | 2 ++
 framework/log.py                    | 2 +-
 framework/profile.py                | 2 +-
 framework/programs/run.py           | 3 +--
 framework/programs/summary.py       | 2 +-
 framework/results.py                | 2 +-
 framework/status.py                 | 2 +-
 framework/test/__init__.py          | 2 +-
 framework/test/base.py              | 2 +-
 framework/test/deqp.py              | 1 +
 framework/test/gleantest.py         | 2 +-
 framework/test/glsl_parser_test.py  | 2 +-
 framework/test/gtest.py             | 2 +-
 framework/test/oclconform.py        | 2 +-
 framework/test/opencv.py            | 2 +-
 framework/test/piglit_test.py       | 2 +-
 framework/test/shader_test.py       | 2 +-
 registry/gl.py                      | 3 +--
 tests/util/gen_dispatch.py          | 2 +-
 unittests/backends_tests.py         | 2 +-
 unittests/base_tests.py             | 2 +-
 unittests/core_tests.py             | 2 +-
 unittests/gleantest_tests.py        | 2 +-
 unittests/glsl_parser_test_tests.py | 2 +-
 unittests/grouptools_tests.py       | 2 +-
 unittests/gtest_tests.py            | 2 +-
 unittests/integration_tests.py      | 2 +-
 unittests/json_backend_tests.py     | 2 +-
 unittests/json_tests.py             | 2 +-
 unittests/junit_backends_tests.py   | 2 +-
 unittests/log_tests.py              | 2 +-
 unittests/oglconform_tests.py       | 1 +
 unittests/opencv_tests.py           | 2 +-
 unittests/piglit_test_tests.py      | 2 +-
 unittests/profile_tests.py          | 2 +-
 unittests/results_tests.py          | 3 +--
 unittests/run_parser_tests.py       | 2 +-
 unittests/shader_test_tests.py      | 2 +-
 unittests/status_tests.py           | 2 +-
 unittests/summary_common_tests.py   | 2 +-
 unittests/test_lists.py             | 2 +-
 unittests/utils.py                  | 2 +-
 48 files changed, 49 insertions(+), 46 deletions(-)

diff --git a/framework/backends/__init__.py b/framework/backends/__init__.py
index b0f784f..1b814a2 100644
--- a/framework/backends/__init__.py
+++ b/framework/backends/__init__.py
@@ -41,6 +41,7 @@ that a user actually wants.
 
 """
 
+from __future__ import absolute_import, division, print_function
 import os
 import importlib
 
diff --git a/framework/backends/abstract.py b/framework/backends/abstract.py
index b8540dd..56aed3f 100644
--- a/framework/backends/abstract.py
+++ b/framework/backends/abstract.py
@@ -25,7 +25,7 @@ This module provides mixins and base classes for backend modules.
 
 """
 
-from __future__ import print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 import abc
 import contextlib
 import itertools
diff --git a/framework/backends/json.py b/framework/backends/json.py
index 99f7e87..8e4dc13 100644
--- a/framework/backends/json.py
+++ b/framework/backends/json.py
@@ -20,7 +20,7 @@
 
 """ Module providing json backend for piglit """
 
-from __future__ import print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 import os
 import sys
 import shutil
diff --git a/framework/backends/junit.py b/framework/backends/junit.py
index 16e5cc1..e6c5d3a 100644
--- a/framework/backends/junit.py
+++ b/framework/backends/junit.py
@@ -20,7 +20,7 @@
 
 """ Module implementing a JUnitBackend for piglit """
 
-from __future__ import print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 import os.path
 import shutil
 
diff --git a/framework/backends/register.py b/framework/backends/register.py
index a52083b..fc3e79b 100644
--- a/framework/backends/register.py
+++ b/framework/backends/register.py
@@ -20,6 +20,7 @@
 
 """An object for registering backends."""
 
+from __future__ import absolute_import, division, print_function
 import collections
 
 Registry = collections.namedtuple(
diff --git a/framework/core.py b/framework/core.py
index 13298a6..bcf4ea5 100644
--- a/framework/core.py
+++ b/framework/core.py
@@ -22,7 +22,7 @@
 
 # Piglit core
 
-from __future__ import print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 import errno
 import os
 import subprocess
diff --git a/framework/grouptools.py b/framework/grouptools.py
index e4157ef..a7f26bd 100644
--- a/framework/grouptools.py
+++ b/framework/grouptools.py
@@ -29,6 +29,8 @@ posix paths they may not start with a leading '/'.
 
 """
 
+from __future__ import absolute_import, division, print_function
+
 __all__ = [
     'SEPARATOR',
     'commonprefix',
diff --git a/framework/log.py b/framework/log.py
index 20a9897..5bd6902 100644
--- a/framework/log.py
+++ b/framework/log.py
@@ -26,7 +26,7 @@ returning BaseLog derived instances to individual tests.
 
 """
 
-from __future__ import print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 import sys
 import abc
 import itertools
diff --git a/framework/profile.py b/framework/profile.py
index 32ed759..94343db 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, absolute_import
+from __future__ import absolute_import, division, print_function
 import os
 import multiprocessing
 import multiprocessing.dummy
diff --git a/framework/programs/run.py b/framework/programs/run.py
index 328e0b0..c4d4770 100644
--- a/framework/programs/run.py
+++ b/framework/programs/run.py
@@ -19,8 +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 absolute_import, division, print_function
 import argparse
 import sys
 import os
diff --git a/framework/programs/summary.py b/framework/programs/summary.py
index b23f1ef..6cf6121 100644
--- a/framework/programs/summary.py
+++ b/framework/programs/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, absolute_import
+from __future__ import absolute_import, division, print_function
 import argparse
 import shutil
 import os
diff --git a/framework/results.py b/framework/results.py
index bdcc993..ffc5287 100644
--- a/framework/results.py
+++ b/framework/results.py
@@ -21,7 +21,7 @@
 
 """ Module for results generation """
 
-from __future__ import print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 
 import collections
 import copy
diff --git a/framework/status.py b/framework/status.py
index 458cd84..d188f16 100644
--- a/framework/status.py
+++ b/framework/status.py
@@ -56,7 +56,7 @@ The formula for determining fixes is:
 
 """
 
-from __future__ import print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 from framework import exceptions
 
 __all__ = ['NOTRUN',
diff --git a/framework/test/__init__.py b/framework/test/__init__.py
index a9b5f4e..1d18364 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 print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 from .base import *
 from .piglit_test import *
 from .gleantest import *
diff --git a/framework/test/base.py b/framework/test/base.py
index 37beb93..faad043 100644
--- a/framework/test/base.py
+++ b/framework/test/base.py
@@ -22,7 +22,7 @@
 
 """ Module provides a base class for Tests """
 
-from __future__ import print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 import errno
 import os
 import time
diff --git a/framework/test/deqp.py b/framework/test/deqp.py
index 5c84131..ae6c591 100644
--- a/framework/test/deqp.py
+++ b/framework/test/deqp.py
@@ -18,6 +18,7 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
 
+from __future__ import absolute_import, division, print_function
 import abc
 import os
 import subprocess
diff --git a/framework/test/gleantest.py b/framework/test/gleantest.py
index acc3983..a12b2ad 100644
--- a/framework/test/gleantest.py
+++ b/framework/test/gleantest.py
@@ -22,7 +22,7 @@
 
 """ Glean support """
 
-from __future__ import print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 import os
 
 from framework import options
diff --git a/framework/test/glsl_parser_test.py b/framework/test/glsl_parser_test.py
index e17fd64..da223fb 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, absolute_import
+from __future__ import absolute_import, division, print_function
 import os
 import re
 
diff --git a/framework/test/gtest.py b/framework/test/gtest.py
index 6eba4cb..547f92a 100644
--- a/framework/test/gtest.py
+++ b/framework/test/gtest.py
@@ -22,7 +22,7 @@
 # Authors: Tom Stellard <thomas.stellard at amd.com>
 #
 
-from __future__ import print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 import re
 
 from .base import Test
diff --git a/framework/test/oclconform.py b/framework/test/oclconform.py
index eb3adb4..8a652f7 100644
--- a/framework/test/oclconform.py
+++ b/framework/test/oclconform.py
@@ -22,7 +22,7 @@
 # Authors: Tom Stellard <thomas.stellard at amd.com>
 #
 
-from __future__ import print_function, print_function
+from __future__ import absolute_import, division, print_function
 import re
 import subprocess
 from os.path import join
diff --git a/framework/test/opencv.py b/framework/test/opencv.py
index 157102e..bb8621b 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, absolute_import
+from __future__ import absolute_import, division, print_function
 import re
 import subprocess
 from os import path
diff --git a/framework/test/piglit_test.py b/framework/test/piglit_test.py
index d173632..998a4ee 100644
--- a/framework/test/piglit_test.py
+++ b/framework/test/piglit_test.py
@@ -22,7 +22,7 @@
 
 """ Module provides a base class for Tests """
 
-from __future__ import print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 import os
 import sys
 import glob
diff --git a/framework/test/shader_test.py b/framework/test/shader_test.py
index dcfc16a..c96b4a7 100644
--- a/framework/test/shader_test.py
+++ b/framework/test/shader_test.py
@@ -23,7 +23,7 @@
 
 """ This module enables running shader tests. """
 
-from __future__ import print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 import re
 
 from framework import exceptions
diff --git a/registry/gl.py b/registry/gl.py
index e87bf5c..98b1ee3 100644
--- a/registry/gl.py
+++ b/registry/gl.py
@@ -23,8 +23,7 @@
 Parse gl.xml into Python objects.
 """
 
-from __future__ import print_function
-
+from __future__ import absolute_import, division, print_function
 
 import os.path
 import re
diff --git a/tests/util/gen_dispatch.py b/tests/util/gen_dispatch.py
index dd05687..a4dbf24 100644
--- a/tests/util/gen_dispatch.py
+++ b/tests/util/gen_dispatch.py
@@ -24,7 +24,7 @@
 Generate C source code from Khronos XML.
 """
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 
 import argparse
 import os.path
diff --git a/unittests/backends_tests.py b/unittests/backends_tests.py
index 29e9a18..54d5e62 100644
--- a/unittests/backends_tests.py
+++ b/unittests/backends_tests.py
@@ -22,7 +22,7 @@
 
 """ Tests for the backend package """
 
-from __future__ import print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 import os
 
 import nose.tools as nt
diff --git a/unittests/base_tests.py b/unittests/base_tests.py
index 68a9c93..37504d9 100644
--- a/unittests/base_tests.py
+++ b/unittests/base_tests.py
@@ -20,7 +20,7 @@
 
 """ Tests for the exectest module """
 
-from __future__ import print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 import tempfile
 import textwrap
 import os
diff --git a/unittests/core_tests.py b/unittests/core_tests.py
index 2699a14..bc80a47 100644
--- a/unittests/core_tests.py
+++ b/unittests/core_tests.py
@@ -20,7 +20,7 @@
 
 """ Module providing tests for the core module """
 
-from __future__ import print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 import os
 import collections
 import shutil
diff --git a/unittests/gleantest_tests.py b/unittests/gleantest_tests.py
index fa732d5..ca06e3b 100644
--- a/unittests/gleantest_tests.py
+++ b/unittests/gleantest_tests.py
@@ -20,7 +20,7 @@
 
 """ Tests for the glean class. Requires Nose """
 
-from __future__ import print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 
 import mock
 import nose.tools as nt
diff --git a/unittests/glsl_parser_test_tests.py b/unittests/glsl_parser_test_tests.py
index 831cde1..629b1d4 100644
--- a/unittests/glsl_parser_test_tests.py
+++ b/unittests/glsl_parser_test_tests.py
@@ -20,7 +20,7 @@
 
 """ Provides tests for the shader_test module """
 
-from __future__ import print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 import os
 import textwrap
 
diff --git a/unittests/grouptools_tests.py b/unittests/grouptools_tests.py
index 3c92d8e..30d0404 100644
--- a/unittests/grouptools_tests.py
+++ b/unittests/grouptools_tests.py
@@ -20,7 +20,7 @@
 
 """Module with tests for grouptools."""
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 
 import nose.tools as nt
 
diff --git a/unittests/gtest_tests.py b/unittests/gtest_tests.py
index 8dd6545..43977aa 100644
--- a/unittests/gtest_tests.py
+++ b/unittests/gtest_tests.py
@@ -20,7 +20,7 @@
 
 """ Module providing tests for gtest """
 
-from __future__ import print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 
 import nose.tools as nt
 
diff --git a/unittests/integration_tests.py b/unittests/integration_tests.py
index dc584b3..596fc54 100644
--- a/unittests/integration_tests.py
+++ b/unittests/integration_tests.py
@@ -26,7 +26,7 @@ errors and to ensure that the API hasn't changed without fixing these modules
 
 """
 
-from __future__ import print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 import importlib
 
 from nose.plugins.skip import SkipTest
diff --git a/unittests/json_backend_tests.py b/unittests/json_backend_tests.py
index 066122a..30a45f7 100644
--- a/unittests/json_backend_tests.py
+++ b/unittests/json_backend_tests.py
@@ -22,7 +22,7 @@
 
 """ Tests for the backend package """
 
-from __future__ import print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 import os
 
 try:
diff --git a/unittests/json_tests.py b/unittests/json_tests.py
index 417b46a..e1cd418 100644
--- a/unittests/json_tests.py
+++ b/unittests/json_tests.py
@@ -26,7 +26,7 @@ tests and they will change with each version of the json output.
 
 """
 
-from __future__ import print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 import os
 
 import nose.tools as nt
diff --git a/unittests/junit_backends_tests.py b/unittests/junit_backends_tests.py
index 1e71f3f..fda76b2 100644
--- a/unittests/junit_backends_tests.py
+++ b/unittests/junit_backends_tests.py
@@ -22,7 +22,7 @@
 
 """ Tests for the backend package """
 
-from __future__ import print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 import os
 
 try:
diff --git a/unittests/log_tests.py b/unittests/log_tests.py
index 1f1cf33..5c7a8ba 100644
--- a/unittests/log_tests.py
+++ b/unittests/log_tests.py
@@ -20,7 +20,7 @@
 
 """ Module provides tests for log.py module """
 
-from __future__ import print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 import sys
 import collections
 import threading
diff --git a/unittests/oglconform_tests.py b/unittests/oglconform_tests.py
index 35a4bdf..5ccb999 100644
--- a/unittests/oglconform_tests.py
+++ b/unittests/oglconform_tests.py
@@ -20,6 +20,7 @@
 
 """Tests for the oglconform integration."""
 
+from __future__ import absolute_import, division, print_function
 from StringIO import StringIO
 
 import mock
diff --git a/unittests/opencv_tests.py b/unittests/opencv_tests.py
index 648f978..94167ff 100644
--- a/unittests/opencv_tests.py
+++ b/unittests/opencv_tests.py
@@ -20,7 +20,7 @@
 
 """ Module for testing opencv """
 
-from __future__ import print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 
 from . import utils
 from framework.test import OpenCVTest
diff --git a/unittests/piglit_test_tests.py b/unittests/piglit_test_tests.py
index 1866296..f299af5 100644
--- a/unittests/piglit_test_tests.py
+++ b/unittests/piglit_test_tests.py
@@ -20,7 +20,7 @@
 
 """Tests for the piglit_test module"""
 
-from __future__ import print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 
 import mock
 import nose.tools as nt
diff --git a/unittests/profile_tests.py b/unittests/profile_tests.py
index 3d78afb..ca1aca4 100644
--- a/unittests/profile_tests.py
+++ b/unittests/profile_tests.py
@@ -20,7 +20,7 @@
 
 """ Provides test for the framework.profile modules """
 
-from __future__ import print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 import sys
 import copy
 
diff --git a/unittests/results_tests.py b/unittests/results_tests.py
index 6a610f0..d40614e 100644
--- a/unittests/results_tests.py
+++ b/unittests/results_tests.py
@@ -20,8 +20,7 @@
 
 """ Module providing tests for the core module """
 
-
-from __future__ import print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 
 import nose.tools as nt
 
diff --git a/unittests/run_parser_tests.py b/unittests/run_parser_tests.py
index 3dd87cc..bce8189 100644
--- a/unittests/run_parser_tests.py
+++ b/unittests/run_parser_tests.py
@@ -20,7 +20,7 @@
 
 """ Module of tests for the run commandline parser """
 
-from __future__ import print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 import sys
 import os
 import shutil
diff --git a/unittests/shader_test_tests.py b/unittests/shader_test_tests.py
index 1c9cec8..5feda63 100644
--- a/unittests/shader_test_tests.py
+++ b/unittests/shader_test_tests.py
@@ -20,7 +20,7 @@
 
 """ Provides tests for the shader_test module """
 
-from __future__ import print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 import os
 
 import mock
diff --git a/unittests/status_tests.py b/unittests/status_tests.py
index c3c3b8a..f1ba96d 100644
--- a/unittests/status_tests.py
+++ b/unittests/status_tests.py
@@ -25,7 +25,7 @@ etc
 
 """
 
-from __future__ import print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 import itertools
 
 import nose.tools as nt
diff --git a/unittests/summary_common_tests.py b/unittests/summary_common_tests.py
index 81dd921..93fecaf 100644
--- a/unittests/summary_common_tests.py
+++ b/unittests/summary_common_tests.py
@@ -21,7 +21,7 @@
 
 """ Module providing tests for the summary module """
 
-from __future__ import print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 import datetime
 
 import nose.tools as nt
diff --git a/unittests/test_lists.py b/unittests/test_lists.py
index e56714b..f56f979 100644
--- a/unittests/test_lists.py
+++ b/unittests/test_lists.py
@@ -26,7 +26,7 @@ es3conform, etc)
 
 """
 
-from __future__ import print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 import importlib
 import os.path as path
 
diff --git a/unittests/utils.py b/unittests/utils.py
index aaf782c..190056d 100644
--- a/unittests/utils.py
+++ b/unittests/utils.py
@@ -25,7 +25,7 @@ in a single place.
 
 """
 
-from __future__ import print_function, absolute_import
+from __future__ import absolute_import, division, print_function
 import os
 import sys
 import copy
-- 
2.7.0



More information about the Piglit mailing list