Fix failures from missing pipfile before install

Signed-off-by: Dan Ryan <dan@danryan.co>
This commit is contained in:
Dan Ryan
2018-11-20 11:27:31 -05:00
parent 0bf7a48451
commit feab1aed39
2 changed files with 5 additions and 2 deletions
+3 -2
View File
@@ -223,13 +223,14 @@ class _PipenvInstance(object):
os.umask(self.original_umask)
def pipenv(self, cmd, block=True):
if self.pipfile_path:
if self.pipfile_path and os.path.isfile(self.pipfile_path):
os.environ['PIPENV_PIPFILE'] = fs_str(self.pipfile_path)
# a bit of a hack to make sure the virtualenv is created
with TemporaryDirectory(prefix='pipenv-', suffix='-cache') as tempdir:
os.environ['PIPENV_CACHE_DIR'] = fs_str(tempdir.name)
c = delegator.run('pipenv {0}'.format(cmd), block=block)
c = delegator.run('pipenv {0}'.format(cmd), block=block,
cwd=os.path.abspath(self.path))
if 'PIPENV_CACHE_DIR' in os.environ:
del os.environ['PIPENV_CACHE_DIR']
+2
View File
@@ -425,6 +425,8 @@ def test_install_creates_pipfile(PipenvInstance):
with PipenvInstance(chdir=True) as p:
if os.path.isfile(p.pipfile_path):
os.unlink(p.pipfile_path)
if "PIPENV_PIPFILE" in os.environ:
del os.environ["PIPENV_PIPFILE"]
assert not os.path.isfile(p.pipfile_path)
c = p.pipenv("install")
assert c.return_code == 0