def wrapped(*args, **kwargs): orig_backend = plt.get_backend() plt.switch_backend('agg') mpl_setup() if plt.get_fignums(): warnings.warn('Figures existed before running the %s %s test.' ' All figures should be closed after they run. ' 'They will be closed automatically now.' % (mod_name, test_name)) plt.close('all') if MPL_VERSION >= '2': style_context = mpl.style.context else: @contextlib.contextmanager def style_context(style, after_reset=False): yield with style_context(self.style): if MPL_VERSION >= '3.2.0': mpl.rcParams['text.kerning_factor'] = 6 r = test_func(*args, **kwargs) figures = [plt.figure(num) for num in plt.get_fignums()] try: self.run_figure_comparisons(figures, test_name=mod_name) finally: for figure in figures: plt.close(figure) plt.switch_backend(orig_backend) return r
def wrapped(*args, **kwargs): orig_backend = plt.get_backend() plt.switch_backend('agg') mpl_setup() if pyplot_helpers.Gcf.figs: warnings.warn('Figures existed before running the %s %s test.' ' All figures should be closed after they run. ' 'They will be closed automatically now.' % (mod_name, test_name)) pyplot_helpers.Gcf.destroy_all() if MPL_VERSION >= '2': style_context = mpl.style.context else: @contextlib.contextmanager def style_context(style, after_reset=False): yield with style_context('classic'): r = test_func(*args, **kwargs) fig_managers = pyplot_helpers.Gcf._activeQue figures = [manager.canvas.figure for manager in fig_managers] try: self.run_figure_comparisons(figures, test_name=mod_name) finally: for figure in figures: pyplot_helpers.Gcf.destroy_fig(figure) plt.switch_backend(orig_backend) return r
def wrapped(*args, **kwargs): orig_backend = plt.get_backend() plt.switch_backend('agg') mpl_setup() if pyplot_helpers.Gcf.figs: warnings.warn('Figures existed before running the %s %s test.' ' All figures should be closed after they run. ' 'They will be closed automatically now.' % (mod_name, test_name)) pyplot_helpers.Gcf.destroy_all() if MPL_VERSION >= '2': style_context = mpl.style.context else: @contextlib.contextmanager def style_context(style, after_reset=False): yield with style_context(self.style): r = test_func(*args, **kwargs) fig_managers = pyplot_helpers.Gcf._activeQue figures = [manager.canvas.figure for manager in fig_managers] try: self.run_figure_comparisons(figures, test_name=mod_name) finally: for figure in figures: pyplot_helpers.Gcf.destroy_fig(figure) plt.switch_backend(orig_backend) return r