예제 #1
0
def envpath_no_venv(request, monkeypatch_sess):
    """Strip virtualenv path from system environment $PATH (scope: session).

    For the test remove virtualenv path from $PATH.

    We use this fixture here to ensure that virtualenvs can be used in
    tests but do not interfere with `unoconv` path and needed libs.

    In other words: with this fixture we can run tests in Python
    versions, that normally do not support `uno` and other packages
    needed by `unoconv`.
    """
    new_path = envpath_wo_virtualenvs()
    if not new_path:
        return
    monkeypatch_sess.setenv("PATH", new_path)
예제 #2
0
def envpath_no_venv(request, monkeypatch_sess):
    """Strip virtualenv path from system environment $PATH (scope: session).

    For the test remove virtualenv path from $PATH.

    We use this fixture here to ensure that virtualenvs can be used in
    tests but do not interfere with `unoconv` path and needed libs.

    In other words: with this fixture we can run tests in Python
    versions, that normally do not support `uno` and other packages
    needed by `unoconv`.
    """
    new_path = envpath_wo_virtualenvs()
    if not new_path:
        return
    monkeypatch_sess.setenv("PATH", new_path)
예제 #3
0
def get_unoconv_version():
    workdir = tempfile.mkdtemp()
    output_path = os.path.join(workdir, 'output')
    os.system('unoconv --version > %s' % output_path)
    output = open(output_path, 'r').readlines()
    if not output:
        # in virtualenvs we might be unable to run unoconv.
        # The workaround will retry with $PATH from special helper function.
        old_env = os.getenv("PATH")
        new_env = envpath_wo_virtualenvs()
        os.environ["PATH"] = new_env
        os.system('unoconv --version > %s' % output_path)
        os.environ["PATH"] = old_env
        output = open(output_path, 'r').readlines()
    version = output[0].split()[-1].split('.')
    shutil.rmtree(workdir)
    return tuple(version)
예제 #4
0
def get_unoconv_version():
    workdir = tempfile.mkdtemp()
    output_path = os.path.join(workdir, 'output')
    os.system('unoconv --version > %s' % output_path)
    output = open(output_path, 'r').readlines()
    if not output:
        # in virtualenvs we might be unable to run unoconv.
        # The workaround will retry with $PATH from special helper function.
        old_env = os.getenv("PATH")
        new_env = envpath_wo_virtualenvs()
        os.environ["PATH"] = new_env
        os.system('unoconv --version > %s' % output_path)
        os.environ["PATH"] = old_env
        output = open(output_path, 'r').readlines()
    version = output[0].split()[-1].split('.')
    shutil.rmtree(workdir)
    return tuple(version)
예제 #5
0
 def test_no_PATH_set(self, monkeypatch):
     # we require $PATH to be set.
     monkeypatch.delenv("PATH", raising=False)
     assert envpath_wo_virtualenvs() is None
예제 #6
0
 def test_venv_and_old_venv_set(self, monkeypatch):
     # with $VIRTUAL_ENV_BEFORE_TOX we get additional dirs removed
     monkeypatch.setenv("PATH", "/env2/.tox/bin:/env1/bin:/foo")
     monkeypatch.setenv("VIRTUAL_ENV", "/env2/.tox")
     monkeypatch.setenv("VIRTUAL_ENV_BEFORE_TOX", "/env1")
     assert envpath_wo_virtualenvs() == "/foo"
예제 #7
0
 def test_single_virt_env_set(self, monkeypatch):
     # with a single virtual env set we get a path list without it.
     monkeypatch.setenv("PATH", "/myvenv1/bin:/foo")
     monkeypatch.setenv("VIRTUAL_ENV", "/myvenv1")
     assert envpath_wo_virtualenvs() == "/foo"
예제 #8
0
 def test_no_VIRTUAL_ENV_set(self, monkeypatch):
     # we require $VIRTUAL_ENV to be set.
     monkeypatch.setenv("PATH", "/tmp:/foo")
     monkeypatch.delenv("VIRTUAL_ENV", raising=False)
     assert envpath_wo_virtualenvs() == "/tmp:/foo"