diff options
author | Dylan Baker <baker.dylan.c@gmail.com> | 2016-01-12 16:01:02 -0800 |
---|---|---|
committer | Dylan Baker <baker.dylan.c@gmail.com> | 2016-02-08 12:29:34 -0800 |
commit | 60d848ed60997352e3ce375974a8202784261488 (patch) | |
tree | 4be70964d9d80911c0e8595272de75f28d3629c3 /framework | |
parent | a0cb4ea9c28acf664e90a755ee4a48c9c21032ed (diff) |
framework,unittests: use __future__ unicode_literals
Use unicode_literals from __future__. This makes undecorated strings
(those not using and b or u prefix) into unicode instead of bytes in
python 2. This means that bytes strings need to have a b prefix now.
This also fixes a couple of unittests that broke during the transition.
Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
Acked-by: Jose Fonseca <jfonseca@vmware.com>
Diffstat (limited to 'framework')
34 files changed, 134 insertions, 58 deletions
diff --git a/framework/backends/__init__.py b/framework/backends/__init__.py index 48c791716..78213755f 100644 --- a/framework/backends/__init__.py +++ b/framework/backends/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2014, 2015 Intel Corporation +# Copyright (c) 2014-2016 Intel Corporation # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -41,7 +41,9 @@ that a user actually wants. """ -from __future__ import absolute_import, division, print_function +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) import os import importlib diff --git a/framework/backends/abstract.py b/framework/backends/abstract.py index c0c890335..b5b485842 100644 --- a/framework/backends/abstract.py +++ b/framework/backends/abstract.py @@ -1,4 +1,4 @@ -# Copyright (c) 2014 Intel Corporation +# Copyright (c) 2014, 2016 Intel Corporation # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -25,7 +25,9 @@ This module provides mixins and base classes for backend modules. """ -from __future__ import absolute_import, division, print_function +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) import abc import contextlib import itertools diff --git a/framework/backends/compression.py b/framework/backends/compression.py index 420c06815..a1b9adefc 100644 --- a/framework/backends/compression.py +++ b/framework/backends/compression.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015 Intel Corporation +# Copyright (c) 2015-2016 Intel Corporation # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -37,7 +37,9 @@ the best way to get a compressor. """ -from __future__ import print_function, absolute_import, division +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) import bz2 import errno import functools diff --git a/framework/backends/json.py b/framework/backends/json.py index 88702e86f..beae8f883 100644 --- a/framework/backends/json.py +++ b/framework/backends/json.py @@ -1,4 +1,4 @@ -# Copyright (c) 2014 Intel Corporation +# Copyright (c) 2014,2016 Intel Corporation # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,9 @@ """ Module providing json backend for piglit """ -from __future__ import absolute_import, division, print_function +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) import os import sys import shutil diff --git a/framework/backends/junit.py b/framework/backends/junit.py index cf48b40ae..062c0615e 100644 --- a/framework/backends/junit.py +++ b/framework/backends/junit.py @@ -1,4 +1,4 @@ -# Copyright (c) 2014, 2015 Intel Corporation +# Copyright (c) 2014-2016 Intel Corporation # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,9 @@ """ Module implementing a JUnitBackend for piglit """ -from __future__ import absolute_import, division, print_function +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) import os.path import shutil diff --git a/framework/backends/register.py b/framework/backends/register.py index fc3e79b55..8d30d3e7b 100644 --- a/framework/backends/register.py +++ b/framework/backends/register.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015 Intel Corporation +# Copyright (c) 2015-2016 Intel Corporation # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,9 @@ """An object for registering backends.""" -from __future__ import absolute_import, division, print_function +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) import collections Registry = collections.namedtuple( diff --git a/framework/compat.py b/framework/compat.py index 8369c0e54..3c8e49009 100644 --- a/framework/compat.py +++ b/framework/compat.py @@ -24,7 +24,9 @@ This function is pending upstreaming in six. """ -from __future__ import absolute_import, division, print_function +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) import six diff --git a/framework/core.py b/framework/core.py index fbe7377f3..5ef72cb65 100644 --- a/framework/core.py +++ b/framework/core.py @@ -22,7 +22,9 @@ # Piglit core -from __future__ import absolute_import, division, print_function +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) import errno import os import subprocess diff --git a/framework/dmesg.py b/framework/dmesg.py index c33dd1166..7bf18d18e 100644 --- a/framework/dmesg.py +++ b/framework/dmesg.py @@ -1,4 +1,4 @@ -# Copyright (c) 2013-2014 Intel Corporation +# Copyright (c) 2013-2016 Intel Corporation # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), @@ -35,7 +35,9 @@ dmesg implementation for their OS. """ -from __future__ import absolute_import, division, print_function +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) import abc import gzip import re @@ -145,7 +147,7 @@ class BaseDmesg(object): result.subtests[key] = replace(value) # Add the dmesg values to the result - result.dmesg = "\n".join(self._new_messages) + result.dmesg = "\n".join(self._new_messages).decode('utf-8') return result @@ -172,9 +174,9 @@ class LinuxDmesg(BaseDmesg): # First check to see if we can find the live kernel config. try: - with gzip.open("/proc/config.gz", 'r') as f: + with gzip.open(b"/proc/config.gz", 'r') as f: for line in f: - if line.startswith("CONFIG_PRINTK_TIME=y"): + if line.startswith(b"CONFIG_PRINTK_TIME=y"): return # If there is a malformed or missing file, just ignore it and try the # regex match (which may not exist if dmesg ringbuffer was cleared). diff --git a/framework/grouptools.py b/framework/grouptools.py index 9d16c2cbc..c3761c766 100644 --- a/framework/grouptools.py +++ b/framework/grouptools.py @@ -1,4 +1,4 @@ -# Copyright (c) 2014, 2015 Intel Corporation +# Copyright (c) 2014-2016 Intel Corporation # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,9 @@ posix paths they may not start with a leading '/'. """ -from __future__ import absolute_import, division, print_function +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) import six from six.moves import zip diff --git a/framework/log.py b/framework/log.py index 12ff7ca1a..cd6cdc58c 100644 --- a/framework/log.py +++ b/framework/log.py @@ -1,4 +1,4 @@ -# Copyright (c) 2013 Intel Corporation +# Copyright (c) 2013-2016 Intel Corporation # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), @@ -26,7 +26,9 @@ returning BaseLog derived instances to individual tests. """ -from __future__ import absolute_import, division, print_function +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) import sys import abc import itertools diff --git a/framework/options.py b/framework/options.py index 78a020f74..cf49520d9 100644 --- a/framework/options.py +++ b/framework/options.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015 Intel Corporation +# Copyright (c) 2015-2016 Intel Corporation # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -25,7 +25,9 @@ is that while you can mutate """ -from __future__ import absolute_import, division, print_function +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) import collections import os import re diff --git a/framework/profile.py b/framework/profile.py index 4ab39c0a5..fc38c56e1 100644 --- a/framework/profile.py +++ b/framework/profile.py @@ -26,7 +26,9 @@ are represented by a TestProfile or a TestProfile derived object. """ -from __future__ import absolute_import, division, print_function +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) import os import multiprocessing import multiprocessing.dummy diff --git a/framework/programs/parsers.py b/framework/programs/parsers.py index 572ac1870..9e1d1e3bd 100644 --- a/framework/programs/parsers.py +++ b/framework/programs/parsers.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015 Intel Corporation +# Copyright (c) 2015-2016 Intel Corporation # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -27,7 +27,9 @@ argumetns early and acting on them, or by inheriting from a parent object. """ -from __future__ import absolute_import, division, print_function +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) import argparse from framework import core diff --git a/framework/programs/run.py b/framework/programs/run.py index 3bad41aa6..49f7b11ac 100644 --- a/framework/programs/run.py +++ b/framework/programs/run.py @@ -19,7 +19,9 @@ # OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -from __future__ import absolute_import, division, print_function +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) import argparse import sys import os diff --git a/framework/programs/summary.py b/framework/programs/summary.py index 4137cf308..949c62882 100644 --- a/framework/programs/summary.py +++ b/framework/programs/summary.py @@ -19,7 +19,9 @@ # OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -from __future__ import absolute_import, division, print_function +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) import argparse import shutil import os diff --git a/framework/results.py b/framework/results.py index b18dce56d..3bc536335 100644 --- a/framework/results.py +++ b/framework/results.py @@ -21,7 +21,9 @@ """ Module for results generation """ -from __future__ import absolute_import, division, print_function +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) import collections import copy import datetime diff --git a/framework/status.py b/framework/status.py index 665c972ad..4c8b421f7 100644 --- a/framework/status.py +++ b/framework/status.py @@ -56,7 +56,9 @@ The formula for determining fixes is: """ -from __future__ import absolute_import, division, print_function +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) import six diff --git a/framework/summary/__init__.py b/framework/summary/__init__.py index 0f0f144f0..e24b26890 100644 --- a/framework/summary/__init__.py +++ b/framework/summary/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015 Intel Corporation +# Copyright (c) 2015-2016 Intel Corporation # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -24,6 +24,8 @@ # generator functions up, allow for better testing coverage. Then we import the # public parts here, so that we have a nice interface to work with. -from __future__ import absolute_import, division, print_function +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) from .html_ import html, feat from .console_ import console diff --git a/framework/summary/common.py b/framework/summary/common.py index e5e670b89..364f3e04d 100644 --- a/framework/summary/common.py +++ b/framework/summary/common.py @@ -1,4 +1,4 @@ -# Copyright 2013-2015 Intel Corporation +# Copyright 2013-2016 Intel Corporation # Copyright 2013, 2014 Advanced Micro Devices # Copyright 2014 VMWare @@ -22,7 +22,9 @@ """Shared functions for summary generation.""" -from __future__ import absolute_import, division, print_function +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) import re import operator diff --git a/framework/summary/console_.py b/framework/summary/console_.py index b3945d4d8..e17a1d8c1 100644 --- a/framework/summary/console_.py +++ b/framework/summary/console_.py @@ -1,4 +1,4 @@ -# Copyright 2013-2015 Intel Corporation +# Copyright 2013-2016 Intel Corporation # Copyright 2013, 2014 Advanced Micro Devices # Copyright 2014 VMWare @@ -22,7 +22,9 @@ """Generate text summaries to be printed to the console.""" -from __future__ import absolute_import, division, print_function +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) import textwrap import six diff --git a/framework/summary/feature.py b/framework/summary/feature.py index 2fb8f50e3..7298cff51 100644 --- a/framework/summary/feature.py +++ b/framework/summary/feature.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015 Intel Corporation +# Copyright (c) 2015-2016 Intel Corporation # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation @@ -21,7 +21,9 @@ # OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -from __future__ import print_function, division, absolute_import +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) import copy diff --git a/framework/summary/html_.py b/framework/summary/html_.py index d36920456..d89ae97ae 100644 --- a/framework/summary/html_.py +++ b/framework/summary/html_.py @@ -1,4 +1,4 @@ -# Copyright 2013-2015 Intel Corporation +# Copyright 2013-2016 Intel Corporation # Copyright 2013, 2014 Advanced Micro Devices # Copyright 2014 VMWare @@ -22,7 +22,9 @@ """Genrate html summaries.""" -from __future__ import absolute_import, division, print_function +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) import os import shutil import tempfile diff --git a/framework/test/__init__.py b/framework/test/__init__.py index 1d1836420..edb4d3e03 100644 --- a/framework/test/__init__.py +++ b/framework/test/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2014 Intel Corporation +# Copyright (c) 2014,2016 Intel Corporation # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -24,7 +24,9 @@ # create a general use API, but allow it to be controlled by setting the # __all__ in each module -from __future__ import absolute_import, division, print_function +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) from .base import * from .piglit_test import * from .gleantest import * diff --git a/framework/test/base.py b/framework/test/base.py index f65a839f0..159ab50d4 100644 --- a/framework/test/base.py +++ b/framework/test/base.py @@ -22,7 +22,9 @@ """ Module provides a base class for Tests """ -from __future__ import absolute_import, division, print_function +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) import errno import os import time diff --git a/framework/test/deqp.py b/framework/test/deqp.py index bfe228e41..0c4b8a04d 100644 --- a/framework/test/deqp.py +++ b/framework/test/deqp.py @@ -1,4 +1,4 @@ -# Copyright 2014, 2015 Intel Corporation +# Copyright 2014-2016 Intel Corporation # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -18,7 +18,9 @@ # 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 +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) import abc import os import subprocess diff --git a/framework/test/gleantest.py b/framework/test/gleantest.py index a12b2aded..3d0c2efbd 100644 --- a/framework/test/gleantest.py +++ b/framework/test/gleantest.py @@ -22,7 +22,9 @@ """ Glean support """ -from __future__ import absolute_import, division, print_function +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) import os from framework import options diff --git a/framework/test/glsl_parser_test.py b/framework/test/glsl_parser_test.py index da223fbf3..73224c691 100644 --- a/framework/test/glsl_parser_test.py +++ b/framework/test/glsl_parser_test.py @@ -21,7 +21,9 @@ """ This module enables the running of GLSL parser tests. """ -from __future__ import absolute_import, division, print_function +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) import os import re diff --git a/framework/test/gtest.py b/framework/test/gtest.py index 547f92a2f..b331a2fb3 100644 --- a/framework/test/gtest.py +++ b/framework/test/gtest.py @@ -1,3 +1,4 @@ +# Copyright 2016 Intel Corporation # Copyright 2013, 2014 Advanced Micro Devices, Inc. # # Permission is hereby granted, free of charge, to any person obtaining a @@ -22,7 +23,9 @@ # Authors: Tom Stellard <thomas.stellard@amd.com> # -from __future__ import absolute_import, division, print_function +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) import re from .base import Test diff --git a/framework/test/oclconform.py b/framework/test/oclconform.py index 8a652f7c4..48e4b72ab 100644 --- a/framework/test/oclconform.py +++ b/framework/test/oclconform.py @@ -1,3 +1,4 @@ +# Copyright 2016 Intel Corporation # Copyright 2014 Advanced Micro Devices, Inc. # # Permission is hereby granted, free of charge, to any person obtaining a @@ -22,7 +23,9 @@ # Authors: Tom Stellard <thomas.stellard@amd.com> # -from __future__ import absolute_import, division, print_function +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) import re import subprocess from os.path import join diff --git a/framework/test/opencv.py b/framework/test/opencv.py index bb8621ba1..3b9a12e43 100644 --- a/framework/test/opencv.py +++ b/framework/test/opencv.py @@ -1,3 +1,4 @@ +# Copyright 2016 Intel Corporation # Copyright 2014 Advanced Micro Devices, Inc. # # Permission is hereby granted, free of charge, to any person obtaining a @@ -22,7 +23,9 @@ # Authors: Tom Stellard <thomas.stellard@amd.com> # -from __future__ import absolute_import, division, print_function +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) import re import subprocess from os import path diff --git a/framework/test/opengl.py b/framework/test/opengl.py index af0cc560b..755e3e3f4 100644 --- a/framework/test/opengl.py +++ b/framework/test/opengl.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015 Intel Corporation +# Copyright (c) 2015-2016 Intel Corporation # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,9 @@ """Mixins for OpenGL derived tests.""" -from __future__ import absolute_import, division, print_function +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) import errno import os import subprocess diff --git a/framework/test/piglit_test.py b/framework/test/piglit_test.py index 998a4eed0..32a991b1a 100644 --- a/framework/test/piglit_test.py +++ b/framework/test/piglit_test.py @@ -22,7 +22,9 @@ """ Module provides a base class for Tests """ -from __future__ import absolute_import, division, print_function +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) import os import sys import glob diff --git a/framework/test/shader_test.py b/framework/test/shader_test.py index c96b4a7fa..f5c26baba 100644 --- a/framework/test/shader_test.py +++ b/framework/test/shader_test.py @@ -1,4 +1,4 @@ -# Copyright (C) 2012, 2014, 2015 Intel Corporation +# Copyright (C) 2012, 2014-2016 Intel Corporation # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation @@ -23,9 +23,13 @@ """ This module enables running shader tests. """ -from __future__ import absolute_import, division, print_function +from __future__ import ( + absolute_import, division, print_function, unicode_literals +) import re +import six + from framework import exceptions from .opengl import FastSkipMixin from .piglit_test import PiglitBaseTest @@ -57,7 +61,10 @@ class ShaderTest(FastSkipMixin, PiglitBaseTest): # an exception. The second looks for the GL version or raises an # exception with open(filename, 'r') as shader_file: - lines = (l for l in shader_file.readlines()) + if six.PY3: + lines = (l for l in shader_file.readlines()) + elif six.PY2: + lines = (l.decode('utf-8') for l in shader_file.readlines()) # Find the config section for line in lines: |