def test_no_runner_found(): # Check that we get EnvironmentError if neither OOMMF nor docker are found if sys.platform == 'win32' and (('Continuum' in sys.version) or ('Anaconda' in sys.version)): pytest.skip("Can't prevent finding oommmf in windows conda env") with testpath.modified_env({'OOMMFTCL': None}): with pytest.raises(EnvironmentError): get_oommf_runner(use_cache=False, docker_exe=nonexistant_docker, oommf_exe=nonexistant_docker)
def test_cached_oommf_runner(): oommf_runner = oo.get_oommf_runner(use_cache=False, envvar='wrong_name', oommf_exe='oommf', docker_exe='wrong_name') assert isinstance(oommf_runner, oo.ExeOOMMFRunner) oommf_runner = oo.get_oommf_runner(use_cache=True) assert isinstance(oommf_runner, oo.ExeOOMMFRunner) oommf_runner = oo.get_oommf_runner(use_cache=True, envvar='OOMMFTCL', oommf_exe='wrong_name', docker_exe='wrong_name') assert isinstance(oommf_runner, oo.ExeOOMMFRunner)
def test_get_right_oommf_runner(): # TclOOMMFRunner oommf_runner = oo.get_oommf_runner(use_cache=False, envvar='OOMMFTCL', oommf_exe='wrong_name', docker_exe='wrong_name') assert isinstance(oommf_runner, oo.TclOOMMFRunner) # ExeOOMMFRunner oommf_runner = oo.get_oommf_runner(use_cache=False, envvar='wrong_name', oommf_exe='oommf', docker_exe='wrong_name') assert isinstance(oommf_runner, oo.ExeOOMMFRunner) # OOMMF cannot be found on the system. with pytest.raises(EnvironmentError): oommf_runner = oo.get_oommf_runner(use_cache=False, envvar='wrong_name', oommf_exe='wrong_name', docker_exe='wrong_name')
def test_docker_oommf_runner(): """DockerOOMMFRunner runs when docker is installed. """ docker_exe = "docker" image = 'joommf/oommf' oommf_runner = oo.DockerOOMMFRunner(docker_exe, image) check_runner(oommf_runner) oommf_runner = oo.get_oommf_runner(use_cache=False, envvar='wrong_name', oommf_exe='wrong_name', docker_exe='docker') assert isinstance(oommf_runner, oo.DockerOOMMFRunner)
def test_docker_oommf_runner(): # DockerOOMMFRunner runs when docker is installed. This test does not run # on host or TravisCI. It can be run using make test-docker on host if # docker is installed. docker_exe = 'docker' image = 'ubermag/oommf' runner = oo.DockerOOMMFRunner(docker_exe, image) check_runner(runner) # An additional check of getting OOMMF runner when docker is installed. runner = oo.get_oommf_runner(use_cache=False, envvar='wrong_name', oommf_exe='wrong_name', docker_exe='docker') assert isinstance(runner, oo.DockerOOMMFRunner) check_runner(runner) with pytest.raises(EnvironmentError): errors = runner.errors()
def test_runtimeerror(): oommf_runner = oo.get_oommf_runner(use_cache=False) with pytest.raises(RuntimeError): oommf_runner.call("+wrong_argstr")
def test_get_oommf_runner(): oommf_runner = oo.get_oommf_runner(use_cache=False) assert isinstance(oommf_runner, oo.OOMMFRunner) check_runner(oommf_runner)
def test_get_oommf_runner(): # This is a shorter version of the previous test for testing on host. oommf_runner = oo.get_oommf_runner(use_cache=False) assert isinstance(oommf_runner, oo.OOMMFRunner) check_runner(oommf_runner)