def _test_demo(demo): import sys sys._called_from_test = True def nop(*args, **kwargs): pass try: from matplotlib import pyplot pyplot.show = nop except ImportError: pass try: import dolfin dolfin.plot = nop dolfin.interactive = nop except ImportError: pass result = None try: result = demo() except PySideMissing: pytest.xfail("PySide missing") finally: stop_gui_processes() from pymor.parallel.default import _cleanup _cleanup() return result
def test_demos(demo_args): module, args = demo_args import sys sys._called_from_test = True def nop(*args, **kwargs): pass try: from matplotlib import pyplot pyplot.show = nop except ImportError: pass try: import dolfin dolfin.plot = nop dolfin.interactive = nop except ImportError: pass try: ret = _run(module, args) # TODO find a better/tighter assert/way to run the code assert ret is not None except ImportError as ie: assert _is_failed_import_ok(ie), ie finally: stop_gui_processes() from pymor.parallel.default import _cleanup _cleanup()
def _test_demo(demo): import sys sys._called_from_test = True def nop(*args, **kwargs): pass try: from matplotlib import pyplot pyplot.show = nop except ImportError: pass try: import dolfin dolfin.plot = nop except ImportError: pass # reset default RandomState import pymor.tools.random pymor.tools.random._default_random_state = None result = None try: result = demo() except QtMissing: pytest.xfail("Qt missing") except GmshError as ge: # this error is ok if gmsh isn't installed at all, or in the wrong version try: import pygmsh gmsh_major = pygmsh.get_gmsh_major_version() if gmsh_major != 2: pytest.xfail( f'GMSH installed in incompatible major {gmsh_major}') else: raise ge except (ImportError, FileNotFoundError): pytest.xfail(f'GMSH not intalled') else: raise ge finally: stop_gui_processes() from pymor.parallel.default import _cleanup _cleanup() return result
def _test_demo(demo): import sys sys._called_from_test = True def nop(*args, **kwargs): pass try: from matplotlib import pyplot pyplot.show = nop except ImportError: pass try: import dolfin dolfin.plot = nop except ImportError: pass # reset default RandomState import pymor.tools.random pymor.tools.random._default_random_state = None result = None try: result = demo() except QtMissing: pytest.xfail("Qt missing") except GmshError as ge: # this error is ok if gmsh isn't installed at all, or in the wrong version try: import pygmsh gmsh_major = pygmsh.get_gmsh_major_version() if gmsh_major != 2: pytest.xfail(f'GMSH installed in incompatible major {gmsh_major}') else: raise ge except (ImportError, FileNotFoundError): pytest.xfail(f'GMSH not intalled') else: raise ge finally: stop_gui_processes() from pymor.parallel.default import _cleanup _cleanup() return result
def _test_demo(demo): import sys sys._called_from_test = True def nop(*args, **kwargs): pass try: from matplotlib import pyplot pyplot.show = nop except ImportError: pass try: import dolfin dolfin.plot = nop except ImportError: pass # reset default RandomState import pymor.tools.random pymor.tools.random._default_random_state = None result = None try: result = demo() except (QtMissing, GmshMissing, MeshioMissing, TorchMissing) as e: if os.environ.get('DOCKER_PYMOR', False): # these are all installed in our CI env so them missing a grave error raise e else: miss = str(type(e)).replace('Missing', '') pytest.xfail(f'{miss} not installed') finally: stop_gui_processes() from pymor.parallel.default import _cleanup _cleanup() try: from matplotlib import pyplot pyplot.close('all') except ImportError: pass return result
def _test_demo(demo): import sys sys._called_from_test = True def nop(*args, **kwargs): pass try: from matplotlib import pyplot pyplot.show = nop except ImportError: pass try: import dolfin dolfin.plot = nop except ImportError: pass # reset default RandomState import pymor.tools.random pymor.tools.random._default_random_state = None result = None try: result = demo() except QtMissing: pytest.xfail("Qt missing") except GmshMissing: pytest.xfail(f'Gmsh not intalled') except MeshioMissing: pytest.xfail(f'meshio not intalled') finally: stop_gui_processes() from pymor.parallel.default import _cleanup _cleanup() try: from matplotlib import pyplot pyplot.close('all') except ImportError: pass return result