Skip to content

Commit

Permalink
Merge pull request #15 from gtalarico/clean-venv-test-fixtures
Browse files Browse the repository at this point in the history
Removed venv fixtures, replace w fast virtualenv call
  • Loading branch information
gtalarico committed May 16, 2018
2 parents 0aeebc9 + 33e35d3 commit 4260ff1
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 25 deletions.
2 changes: 2 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ History
0.6.1 (2018-05-15)
--------------------------
* Fix Python binary version detect call
* Improved testing speed and fixtures"



0.6.0 (2018-05-15)
Expand Down
25 changes: 13 additions & 12 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
import os
import sys
from subprocess import Popen, PIPE
from contextlib import contextmanager
from tempfile import TemporaryDirectory
import shutil
Expand All @@ -16,7 +16,6 @@
from pipenv_pipes.environment import EnvVars

HERE = os.path.dirname(__file__)
VENVS_ARCHIVE = os.path.join(HERE, 'venvs')


def touch(filename):
Expand All @@ -36,12 +35,16 @@ def env_vars():
return EnvVars()


@pytest.fixture
def venv_archive_path(env_vars):
""" Note: This provides a path to zipped envs create for the
for the purpose of optimizing test run time """
filename = '{}.tar.gz'.format(sys.platform)
return os.path.join(VENVS_ARCHIVE, filename)
@pytest.fixture(scope='session')
def venv_fresh():
with TemporaryDirectory() as folder:
venv_cmd = 'virtualenv --no-pip --no-wheel --no-setuptools'
cmd = '{} {}'.format(venv_cmd, folder)
proc = Popen(cmd.split(' '), stderr=PIPE, stdout=PIPE)
out, err = proc.communicate()
if err:
raise Exception(err)
yield folder


@pytest.fixture
Expand Down Expand Up @@ -102,7 +105,7 @@ def mock_projects_dir(project_names, win_tempdir):


@pytest.fixture
def mock_env_home(TempEnviron, mock_projects_dir, venv_archive_path):
def mock_env_home(TempEnviron, mock_projects_dir, venv_fresh):
__cwd = os.getcwd()
with TemporaryDirectory(prefix='pipenv_home_real') as pipenv_home:

Expand All @@ -118,10 +121,8 @@ def mock_env_home(TempEnviron, mock_projects_dir, venv_archive_path):
envname = project.virtualenv_name
os.chdir(__cwd)

unzip_tar(venv_archive_path, pipenv_home)
fake_env = os.path.join(pipenv_home, 'env')
envpath = os.path.join(pipenv_home, envname)
shutil.move(fake_env, envpath)
shutil.copytree(venv_fresh, envpath)

# Make Project Links
envs = find_environments(pipenv_home)
Expand Down
13 changes: 0 additions & 13 deletions tests/test_tar.py

This file was deleted.

Binary file removed tests/venvs/darwin.tar.gz
Binary file not shown.
Binary file removed tests/venvs/linux.tar.gz
Binary file not shown.
Binary file removed tests/venvs/win32.tar.gz
Binary file not shown.

0 comments on commit 4260ff1

Please sign in to comment.