Make a class for error data
No behavior change.
diff --git a/tests/scripts/test_psa_constant_names.py b/tests/scripts/test_psa_constant_names.py
index e261b4f..5780f25 100755
--- a/tests/scripts/test_psa_constant_names.py
+++ b/tests/scripts/test_psa_constant_names.py
@@ -8,6 +8,7 @@
"""
import argparse
+from collections import namedtuple
import itertools
import os
import platform
@@ -341,6 +342,9 @@
class Tests:
"""An object representing tests and their results."""
+ Error = namedtuple('Error',
+ ['type', 'expression', 'value', 'output'])
+
def __init__(self, options):
self.options = options
self.count = 0
@@ -362,7 +366,10 @@
self.count += len(expressions)
for expr, value, output in zip(expressions, values, outputs):
if normalize(expr) != normalize(output):
- self.errors.append((type_word, expr, value, output))
+ self.errors.append(self.Error(type=type_word,
+ expression=expr,
+ value=value,
+ output=output))
def run_all(self, inputs):
"""Run psa_constant_names on all the gathered inputs."""
@@ -376,9 +383,10 @@
Write the errors to ``out``.
Also write a total.
"""
- for type_word, name, value, output in self.errors:
+ for error in self.errors:
out.write('For {} "{}", got "{}" (value: {})\n'
- .format(type_word, name, output, value))
+ .format(error.type, error.expression,
+ error.output, error.value))
out.write('{} test cases'.format(self.count))
if self.errors:
out.write(', {} FAIL\n'.format(len(self.errors)))