[Piglit] [PATCH 14/26] shader_test.py: PEP8 compliance
Dylan Baker
baker.dylan.c at gmail.com
Wed Jul 10 15:19:05 PDT 2013
---
framework/shader_test.py | 49 ++++++++++++++++++++++++++++--------------------
1 file changed, 29 insertions(+), 20 deletions(-)
diff --git a/framework/shader_test.py b/framework/shader_test.py
index 48a9085..12e8e7e 100755
--- a/framework/shader_test.py
+++ b/framework/shader_test.py
@@ -53,13 +53,15 @@ _HELP_TEXT = textwrap.dedent("""\
DESCRIPTION
This script runs shader tests. Typically, the filename extension for
- shader tests is ".shader_test". The extra_args are passed verbatim
- to the shader_runner executable.
- """.format(progname = _PROGNAME))
+ shader tests is ".shader_test". The extra_args are passed verbatim to
+ the shader_runner executable.
+ """.format(progname=_PROGNAME))
+
def add_shader_test(group, testname, filepath):
group[testname] = ShaderTest([filepath, '-auto'])
+
def add_shader_test_dir(group, dirpath, recursive=False):
"""Add all shader tests in a directory to the given group."""
for filename in os.listdir(dirpath):
@@ -74,11 +76,11 @@ def add_shader_test_dir(group, dirpath, recursive=False):
ext = filename.rsplit('.')[-1]
if ext != 'shader_test':
continue
- testname = filename[0:-(len(ext) + 1)] # +1 for '.'
+ testname = filename[0:-(len(ext) + 1)] # +1 for '.'
add_shader_test(group, testname, filepath)
-class ShaderTest(PlainExecTest):
+class ShaderTest(PlainExecTest):
API_ERROR = 0
API_GL = 1
API_GLES2 = 2
@@ -104,19 +106,21 @@ class ShaderTest(PlainExecTest):
if cls.__has_compiled_regexes:
return
- common = {
- 'cmp' : r'(<|<=|=|>=|>)',
- 'gl_version' : r'(\d.\d)',
- 'gles2_version' : r'(2.\d\s)',
- 'gles3_version' : r'(3.\d\s)',
- 'comment' : r'(#.*)',
- }
+ common = {'cmp': r'(<|<=|=|>=|>)',
+ 'gl_version': r'(\d.\d)',
+ 'gles2_version': r'(2.\d\s)',
+ 'gles3_version': r'(3.\d\s)',
+ 'comment': r'(#.*)'}
- cls.__re_require_header = re.compile(r'^\s*\[require\]\s*{comment}?$'.format(**common))
+ cls.__re_require_header = re.compile(r'^\s*\[require\]'
+ '\s*{comment}?$'.format(**common))
cls.__re_end_require_block = re.compile(r'^\s*\['.format(*common))
- cls.__re_gl = re.compile(r'^\s*GL\s*{cmp}\s*{gl_version}\s*{comment}?$'.format(**common))
- cls.__re_gles2 = re.compile(r'^\s*GL ES\s*{cmp}\s*{gles2_version}\s*{comment}?$'.format(**common))
- cls.__re_gles3 = re.compile(r'^\s*GL ES\s*{cmp}\s*{gles3_version}\s*{comment}?$'.format(**common))
+ cls.__re_gl = re.compile(r'^\s*GL\s*{cmp}\s*{gl_version}\s*{comment}'
+ '?$'.format(**common))
+ cls.__re_gles2 = re.compile(r'^\s*GL ES\s*{cmp}\s*{gles2_version}'
+ '\s*{comment}?$'.format(**common))
+ cls.__re_gles3 = re.compile(r'^\s*GL ES\s*{cmp}\s*{gles3_version}'
+ '\s*{comment}?$'.format(**common))
cls.__re_gl_unknown = re.compile(r'^\s*GL\s*{cmp}'.format(**common))
def __init__(self, shader_runner_args, run_standalone=False):
@@ -125,7 +129,7 @@ class ShaderTest(PlainExecTest):
Test.__init__(self, runConcurrent=True)
assert(isinstance(shader_runner_args, list))
- assert(isinstance(shader_runner_args[0], str) or \
+ assert(isinstance(shader_runner_args[0], str) or
isinstance(shader_runner_args[0], unicode))
self.__run_standalone = run_standalone
@@ -185,10 +189,11 @@ class ShaderTest(PlainExecTest):
self.__gl_api = ShaderTest.API_GLES3
return
elif cls.__re_gl_unknown.match(line) is not None:
- self.__report_failure("Failed to parse GL requirement: " + line)
+ self.__report_failure("Failed to parse GL "
+ "requirement: " + line)
self.__gl_api = ShaderTest.API_ERROR
return
- elif cls.__re_end_require_block.match(line) is not None:
+ elif cls.__re_end_require_block.match(line):
# Default to GL if no API is given.
self.__gl_api = ShaderTest.API_GL
return
@@ -208,7 +213,8 @@ class ShaderTest(PlainExecTest):
assert(False)
except IOError:
- self._report_failure("Failed to read test file {0!r}".format(self.__test_filepath))
+ self._report_failure("Failed to read test file "
+ "{0!r}".format(self.__test_filepath))
return
@property
@@ -253,11 +259,13 @@ class ShaderTest(PlainExecTest):
return PlainExecTest.run(self, valgrind)
+
def _usage_error():
sys.stdout.write("usage error: {0}\n\n".format(_PROGNAME))
sys.stdout.write(_HELP_TEXT)
sys.exit(1)
+
def _main(args):
if len(sys.argv) < 2:
_usage_error()
@@ -265,5 +273,6 @@ def _main(args):
test = ShaderTest(sys.argv[1:], run_standalone=True)
test.run()
+
if __name__ == "__main__":
_main(sys.argv)
--
1.8.3.1
More information about the Piglit
mailing list