From: Thomas Fillon Date: Tue, 24 Jun 2014 15:58:27 +0000 (+0200) Subject: refactor(test_graphers_render_analyzers): Encapsulate test facory in a function X-Git-Tag: 0.6~4^2~81 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=5651295bffd88dbca8c89ea17eba77a287223d54;p=timeside.git refactor(test_graphers_render_analyzers): Encapsulate test facory in a function --- diff --git a/tests/test_graphers_render_analyzers.py b/tests/test_graphers_render_analyzers.py index 5a9dc2f..4ea203b 100644 --- a/tests/test_graphers_render_analyzers.py +++ b/tests/test_graphers_render_analyzers.py @@ -8,7 +8,7 @@ import numpy as np from tempfile import NamedTemporaryFile import os -PLOT = False +PLOT = True class Test_graphers_analyzers(unittest.TestCase): @@ -40,23 +40,25 @@ class Test_graphers_analyzers(unittest.TestCase): # Clean-up : delete temp file os.unlink(self.temp_file.name) -list_graphers = timeside.core.processors(timeside.api.IGrapher) -module = 'timeside.grapher.render_analyzers' -grapher_analyzers = [grapher for grapher in list_graphers - if grapher.__module__ == module] -for grapher in grapher_analyzers: +def _tests_factory(grapher_analyzers): + for grapher in grapher_analyzers: - def _test_func_factory(grapher): - test_func = lambda self: self._perform_test(grapher) - test_func.__doc__ = 'Test Graphers : %s' % grapher.name() - return test_func + def _test_func_factory(grapher): + test_func = lambda self: self._perform_test(grapher) + test_func.__doc__ = 'Test Graphers : %s' % grapher.name() + return test_func - test_func_name = "test_%s" % grapher.name() - test_func = _test_func_factory(grapher) + test_func_name = "test_%s" % grapher.name() + test_func = _test_func_factory(grapher) - setattr(Test_graphers_analyzers, test_func_name, test_func) + setattr(Test_graphers_analyzers, test_func_name, test_func) +list_graphers = timeside.core.processors(timeside.api.IGrapher) +module = 'timeside.grapher.render_analyzers' +grapher_analyzers = [grapher for grapher in list_graphers + if grapher.__module__ == module] +_tests_factory(grapher_analyzers) if __name__ == '__main__': unittest.main(testRunner=TestRunner())