changeset 33866:4e8a46c25fac

run-tests: pre instantiate pygments objects Pre instantiate pygments objects to minimize overhead (cf. 20436925e080)
author Matthieu Laneuville <matthieu.laneuville@octobus.net>
date Tue, 22 Aug 2017 11:00:00 +0200
parents af20468eb0a4
children 252fb66ee5bb
files tests/run-tests.py
diffstat 1 files changed, 9 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/tests/run-tests.py	Mon Aug 21 21:35:06 2017 -0700
+++ b/tests/run-tests.py	Tue Aug 22 11:00:00 2017 +0200
@@ -136,6 +136,9 @@
             ]
         }
 
+    runnerformatter = formatters.Terminal256Formatter(style=TestRunnerStyle)
+    runnerlexer = TestRunnerLexer()
+
 if sys.version_info > (3, 5, 0):
     PYTHON3 = True
     xrange = range # we use xrange in one place, and we'd rather not use range
@@ -1637,9 +1640,8 @@
                         if self.color:
                             formatted = pygments.highlight(
                                 formatted,
-                                TestRunnerLexer(),
-                                formatters.Terminal256Formatter(
-                                            style=TestRunnerStyle))
+                                runnerlexer,
+                                runnerformatter)
                         self.stream.write(formatted)
                     self.stream.write('!')
 
@@ -2046,18 +2048,16 @@
                     if result.color:
                         formatted = pygments.highlight(
                             formatted,
-                            TestRunnerLexer(),
-                            formatters.Terminal256Formatter(
-                                            style=TestRunnerStyle)).strip("\n")
+                            runnerlexer,
+                            runnerformatter).strip("\n")
                     self.stream.writeln(formatted)
             for test, msg in result.failures:
                 formatted = 'Failed %s: %s' % (test.name, msg)
                 if result.color:
                     formatted = pygments.highlight(
                         formatted,
-                        TestRunnerLexer(),
-                        formatters.Terminal256Formatter(
-                                        style=TestRunnerStyle)).strip("\n")
+                        runnerlexer,
+                        runnerformatter).strip("\n")
                 self.stream.writeln(formatted)
             for test, msg in result.errors:
                 self.stream.writeln('Errored %s: %s' % (test.name, msg))