Ejemplo n.º 1
0
def test_getsupportedinterpreter(monkeypatch, newconfig, mocksession):
    config = newconfig(
        [],
        """\
        [testenv:python]
        basepython={}
        """.format(sys.executable, ),
    )
    mocksession.new_config(config)
    venv = mocksession.getvenv("python")
    interp = venv.getsupportedinterpreter()
    # realpath needed for debian symlinks
    assert py.path.local(interp).realpath() == py.path.local(
        sys.executable).realpath()
    monkeypatch.setattr(tox.INFO, "IS_WIN", True)
    monkeypatch.setattr(venv.envconfig, "basepython", "jython")
    with pytest.raises(tox.exception.UnsupportedInterpreter):
        venv.getsupportedinterpreter()
    monkeypatch.undo()
    monkeypatch.setattr(venv.envconfig, "envname", "py1")
    monkeypatch.setattr(venv.envconfig, "basepython", "notexisting")
    with pytest.raises(tox.exception.InterpreterNotFound):
        venv.getsupportedinterpreter()
    monkeypatch.undo()
    # check that we properly report when no version_info is present
    info = NoInterpreterInfo(name=venv.name)
    info.executable = "something"
    monkeypatch.setattr(config.interpreters, "get_info",
                        lambda *args, **kw: info)
    with pytest.raises(tox.exception.InvocationError):
        venv.getsupportedinterpreter()
Ejemplo n.º 2
0
 def test_set_data(self):
     x = NoInterpreterInfo("migraine",
                           executable="my-executable",
                           out="my-out",
                           err="my-err")
     assert x.name == "migraine"
     assert x.executable == "my-executable"
     assert x.version_info is None
     assert x.out == "my-out"
     assert x.err == "my-err"
Ejemplo n.º 3
0
def test_getsupportedinterpreter(monkeypatch, newconfig, mocksession):
    config = newconfig([], """
        [testenv:python]
        basepython=%s
    """ % sys.executable)
    venv = VirtualEnv(config.envconfigs['python'], session=mocksession)
    interp = venv.getsupportedinterpreter()
    # realpath needed for debian symlinks
    assert py.path.local(interp).realpath() == py.path.local(sys.executable).realpath()
    monkeypatch.setattr(sys, 'platform', "win32")
    monkeypatch.setattr(venv.envconfig, 'basepython', 'jython')
    pytest.raises(tox.exception.UnsupportedInterpreter, venv.getsupportedinterpreter)
    monkeypatch.undo()
    monkeypatch.setattr(venv.envconfig, "envname", "py1")
    monkeypatch.setattr(venv.envconfig, 'basepython', 'notexistingpython')
    pytest.raises(tox.exception.InterpreterNotFound, venv.getsupportedinterpreter)
    monkeypatch.undo()
    # check that we properly report when no version_info is present
    info = NoInterpreterInfo(name=venv.name)
    info.executable = "something"
    monkeypatch.setattr(config.interpreters, "get_info", lambda *args, **kw: info)
    pytest.raises(tox.exception.InvocationError, venv.getsupportedinterpreter)
Ejemplo n.º 4
0
 def test_str_with_executable(self):
     x = NoInterpreterInfo("coconut", executable="bang/em/together")
     assert str(x) == "<executable at bang/em/together, not runnable>"
Ejemplo n.º 5
0
 def test_str_without_executable(self):
     x = NoInterpreterInfo("coconut")
     assert str(x) == "<executable not found for: coconut>"
Ejemplo n.º 6
0
 def test_runnable(self):
     assert not NoInterpreterInfo("foo").runnable
     assert not NoInterpreterInfo("foo", executable=sys.executable).runnable