Commit 60d848ed authored by Dylan Baker's avatar Dylan Baker

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: default avatarDylan Baker <dylanx.c.baker@intel.com>
Acked-by: Jose Fonseca's avatarJose Fonseca <jfonseca@vmware.com>
parent a0cb4ea9
# 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
......
# 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
......
# 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
......
# 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
......
# 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
......
# 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(
......
......@@ -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
......
......@@ -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
......
# 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).
......
# 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
......
# 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
......
# 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
......
......@@ -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
......
# 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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
# 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
# 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
......
# 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
......
# 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
......
# 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
......
# 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 *
......
......@@ -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
......
# 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
......
......@@ -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
......
......@@ -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
......
# 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
......
# 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
......
# 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
......
# 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
......
......@@ -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
......
# 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:
......
......@@ -23,7 +23,9 @@
Parse gl.xml into Python objects.
"""
from __future__ import absolute_import, division, print_function
from __future__ import (
absolute_import, division, print_function, unicode_literals
)
import os.path
import re
......@@ -182,7 +184,7 @@ class OrderedKeyedSet(object):
# pair has form {key: [prev, next, key, value])}.
self.__map = dict()
if isinstance(key, str):
if isinstance(key, six.text_type):
self.__key_func = lambda elem: getattr(elem, key)
else:
self.__key_func = key
......
# -*- coding: utf-8 -*-
# All tests that come with piglit, using default settings
from __future__ import print_function, division, absolute_import
from __future__ import (
absolute_import, division, print_function, unicode_literals
)
import itertools
import os
import platform
......
......@@ -7,7 +7,9 @@
# invalid constant names, they're not really fixable, so just hide them.
# pylint: disable=invalid-name
from __future__ import division, absolute_import, print_function
from __future__ import (
absolute_import, division, print_function, unicode_literals
)
import os
......
......@@ -10,6 +10,9 @@ hardware.
"""
from __future__ import (
absolute_import, division, print_function, unicode_literals
)
from tests.quick import profile
from framework.test import GLSLParserTest
......
......@@ -42,7 +42,9 @@ PIGLIT_CTS_EXTRA_ARGS -- environment equivalent of [cts]:extra_args
"""
from __future__ import absolute_import, division, print_function
from __future__ import (
absolute_import, division, print_function, unicode_literals
)
import itertools
from framework.test import deqp
......
......@@ -20,6 +20,10 @@
"""Piglit integrations for dEQP GLES2 tests."""
from __future__ import (
absolute_import, division, print_function, unicode_literals
)
from framework.test import deqp
__all__ = ['profile']
......
......@@ -20,6 +20,10 @@
"""Piglit integrations for dEQP GLES3 tests."""
from __future__ import (
absolute_import, division, print_function, unicode_literals
)
import xml.etree.cElementTree as ET
from framework.test import deqp
......
......@@ -20,6 +20,10 @@
"""Piglit integrations for dEQP GLES31 tests."""
from __future__ import (
absolute_import, division, print_function, unicode_literals
)
from framework.test import deqp
__all__ = ['profile']
......
......@@ -20,6 +20,10 @@
# OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
from __future__ import (
absolute_import, division, print_function, unicode_literals
)
import re
from os import path
......
"""A profile that runs only GLSLParserTest instances."""
from __future__ import (
absolute_import, division, print_function, unicode_literals
)
from framework.test import GLSLParserTest
from tests.all import profile
......
......@@ -2,6 +2,10 @@
# quick.tests minus compiler tests.
from __future__ import (
absolute_import, division, print_function, unicode_literals
)
from tests.quick import profile
from framework.test import GLSLParserTest
......
......@@ -32,7 +32,10 @@ drm. Even if you have rendernode support enabled.
"""
from __future__ import print_function, division, absolute_import
from __future__ import (
absolute_import, division, print_function, unicode_literals
)
import os
import re
import subprocess
......
# -*- coding: utf-8 -*-
from __future__ import (
absolute_import, division, print_function, unicode_literals
)
import platform
import sys
......
......@@ -21,6 +21,9 @@
# OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
from __future__ import (
absolute_import, division, print_function, unicode_literals
)
import os
import re
import subprocess
......
# -*- coding: utf-8 -*-
from __future__ import (
absolute_import, division, print_function, unicode_literals
)
from framework import grouptools
from framework.test import (GleanTest, PiglitGLTest)
from tests.all import profile
......
......@@ -24,6 +24,10 @@
# Authors: Tom Stellard <thomas.stellard@amd.com>
#
from __future__ import (