def test(verbosity=1): """run the ggplot test suite""" old_backend = mpl.rcParams['backend'] try: mpl.use('agg') import nose import nose.plugins.builtin from matplotlib.testing.noseclasses import KnownFailure from nose.plugins.manager import PluginManager from nose.plugins import multiprocess # store the old values before overriding plugins = [] plugins.append( KnownFailure() ) plugins.extend( [plugin() for plugin in nose.plugins.builtin.plugins] ) manager = PluginManager(plugins=plugins) config = nose.config.Config(verbosity=verbosity, plugins=manager) # Nose doesn't automatically instantiate all of the plugins in the # child processes, so we have to provide the multiprocess plugin with # a list. multiprocess._instantiate_plugins = [KnownFailure] success = nose.run( defaultTest=default_test_modules, config=config, ) finally: if old_backend.lower() != 'agg': mpl.use(old_backend) return success
def do_test(): figure = plt.figure(fignum) if self._remove_text: self.remove_text(figure) figure.savefig(actual_fname, **self._savefig_kwarg) plt.close(figure) err = compare_images(expected_fname, actual_fname, self._tol, in_decorator=True) try: if not os.path.exists(expected_fname): raise ImageComparisonFailure( 'image does not exist: %s' % expected_fname) if err: # TODO: uri: Fix this miserable hack: pass #raise ImageComparisonFailure( #'images not close: %(actual)s vs. ' #'%(expected)s (RMS %(rms).3f)' % err) except ImageComparisonFailure: if not check_freetype_version(self._freetype_version): raise KnownFailure( "Mismatched version of freetype. Test requires '%s', you have '%s'" % (self._freetype_version, ft2font.__freetype_version__)) raise
def failer(*args, **kwargs): try: # Always run the test (to generate images). result = f(*args, **kwargs) except Exception as err: if fail_condition: if known_exception_class is not None: if not isinstance(err,known_exception_class): # This is not the expected exception raise # (Keep the next ultra-long comment so in shows in console.) raise KnownFailure(msg) # An error here when running nose means that you don't have the matplotlib.testing.noseclasses:KnownFailure plugin in use. else: raise if fail_condition and fail_condition != 'indeterminate': raise KnownFailureDidNotFailTest(msg) return result
def run(): nose.main(addplugins=[KnownFailure()], defaultTest=default_test_modules)
testgrid = trendvis.YGrid([1, 2, 1]) testgrid.set_xlabels(['0', '1', None]) @cleanup @image_comparison(baseline_images=['xgrid_frame']) def test_xgrid_frame(): testgrid = trendvis.XGrid([1, 2, 1], xratios=[1, 1]) testgrid.cleanup_grid() testgrid.draw_frame() @cleanup @image_comparison(baseline_images=['ygrid_frame']) def test_ygrid_frame(): testgrid = trendvis.YGrid([1, 2, 1], yratios=[1, 1]) testgrid.cleanup_grid() testgrid.draw_frame() if __name__ == '__main__': import nose import sys nose.main(addplugins=[KnownFailure()]) args = ['-s', '--with-doctest'] argv = sys.argv argv = argv[:1] + args + argv[1:] nose.runmodule(argv=argv, exit=False)