Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gtalarico committed May 11, 2018
1 parent b18137d commit 6ef0942
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pipenv_pipes/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ def find_environments(pipenv_home):
def find_binary(envpath):
env_ls = os.listdir(envpath)
if 'bin' in env_ls:
path = os.path.join(envpath, 'bin')
binpath = os.path.join(envpath, 'bin', 'python')
elif 'Scripts' in env_ls:
path = os.path.join(envpath, 'Scripts')
binpath = os.path.join(envpath, 'Scripts', 'python.exe')
else:
return
binpath = os.path.join(path, 'python')
if os.path.exists(binpath):
return binpath
else:
import pdb; pdb.set_trace()
raise EnvironmentError('could not find python binary: {}'.format(envpath))


Expand Down
15 changes: 14 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import pytest
import os
import sys
from contextlib import contextmanager
from tempfile import TemporaryDirectory
from shutil import copy
import time

from click.testing import CliRunner

Expand Down Expand Up @@ -76,8 +79,18 @@ def mock_env_home_empty(TempEnviron, mock_projects_dir):
# https://github.com/pypa/pipenv/blob/master/pipenv/project.py#L223
for project_name in os.listdir(mock_projects_dir):
envname = '{}-12345678'.format(project_name)
os.makedirs(os.path.join(pipenv_home, envname))
envpath = os.path.join(pipenv_home, envname)
python_fp = sys.executable
if python_fp.endswith('exe'):
bin_path = os.path.join(envpath, 'Scripts')
else:
bin_path = os.path.join(envpath, 'bin')
os.makedirs(envpath)
os.makedirs(bin_path)
copy(python_fp, bin_path, follow_symlinks=True)
yield pipenv_home, mock_projects_dir
# Sometimes python.exe is still budy, this give time to unlock
time.sleep(0.1)


@pytest.fixture
Expand Down

0 comments on commit 6ef0942

Please sign in to comment.