Пример #1
0
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)
Пример #2
0
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)
Пример #3
0
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)
Пример #4
0
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')
Пример #5
0
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')
Пример #6
0
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)
Пример #7
0
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)
Пример #8
0
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()
Пример #9
0
def test_runtimeerror():
    oommf_runner = oo.get_oommf_runner(use_cache=False)
    with pytest.raises(RuntimeError):
        oommf_runner.call("+wrong_argstr")
Пример #10
0
def test_get_oommf_runner():
    oommf_runner = oo.get_oommf_runner(use_cache=False)
    assert isinstance(oommf_runner, oo.OOMMFRunner)
    check_runner(oommf_runner)
Пример #11
0
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)
Пример #12
0
def test_runtimeerror():
    oommf_runner = oo.get_oommf_runner(use_cache=False)
    with pytest.raises(RuntimeError):
        oommf_runner.call("+wrong_argstr")
Пример #13
0
def test_get_oommf_runner():
    oommf_runner = oo.get_oommf_runner(use_cache=False)
    assert isinstance(oommf_runner, oo.OOMMFRunner)
    check_runner(oommf_runner)