Example #1
0
def test_without_virtualenv_available(monkeypatch, tmpfolder):
    # When virtualenv is not available
    venv_mock = Mock()
    monkeypatch.setattr(venv, "create_with_stdlib", venv_mock)
    venv.run({}, {"project_path": Path(tmpfolder), "venv": ".venv"})
    # venv will be called
    venv_mock.assert_called_once()
Example #2
0
def test_already_exists(monkeypatch, tmpfolder):
    virtualenv_mock = Mock()
    venv_mock = Mock()
    monkeypatch.setattr(venv, "create_with_virtualenv", virtualenv_mock)
    monkeypatch.setattr(venv, "create_with_stdlib", venv_mock)
    # When the venv directory already exist
    (Path(tmpfolder) / ".venv").mkdir()
    venv.run({}, {"project_path": Path(tmpfolder), "venv": ".venv"})
    # It should skip
    virtualenv_mock.assert_not_called()
    venv_mock.assert_not_called()
Example #3
0
def test_with_none_available(tmpfolder):
    # When virtualenv and venv are not available
    # then an exception will be raised
    with pytest.raises(venv.NotInstalled):
        venv.run({}, {"project_path": Path(tmpfolder), "venv": ".venv"})