mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
Merge pull request #1842 from pypa/bugfix/windows-pipfile-scripts
Fix `shlex.split()` call to check for posix first
This commit is contained in:
+5
-2
@@ -3,6 +3,7 @@ import codecs
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import six
|
||||
import sys
|
||||
import shlex
|
||||
import base64
|
||||
@@ -371,9 +372,11 @@ class Project(object):
|
||||
@property
|
||||
def scripts(self):
|
||||
scripts = self.parsed_pipfile.get('scripts', {})
|
||||
posix = os.name == 'posix'
|
||||
_scripts = {}
|
||||
for (k, v) in scripts.items():
|
||||
scripts[k] = shlex.split(v, posix=True)
|
||||
return scripts
|
||||
_scripts[k] = shlex.split(str(v), posix=posix)
|
||||
return _scripts
|
||||
|
||||
def update_settings(self, d):
|
||||
settings = self.settings
|
||||
|
||||
@@ -1170,3 +1170,38 @@ flask = "==0.12.2"
|
||||
with open(p.pipfile_path, 'a') as f:
|
||||
f.write('requests = "==2.14.0"\n')
|
||||
assert Project().get_lockfile_hash() != Project.calculate_pipfile_hash()
|
||||
|
||||
@pytest.mark.run
|
||||
def test_scripts_basic(self):
|
||||
with PipenvInstance(chdir=True) as p:
|
||||
with open(p.pipfile_path, 'w') as f:
|
||||
f.write("""
|
||||
[scripts]
|
||||
printfoo = "python -c print('foo')"
|
||||
""")
|
||||
|
||||
c = p.pipenv('install')
|
||||
assert c.return_code == 0
|
||||
|
||||
c = p.pipenv('run printfoo')
|
||||
assert c.return_code == 0
|
||||
assert c.out == 'foo\n'
|
||||
assert c.err == ''
|
||||
|
||||
@pytest.mark.run
|
||||
@pytest.mark.skip(reason='This fails on Windows (not sure about POSIX).')
|
||||
def test_scripts_quoted(self):
|
||||
with PipenvInstance(chdir=True) as p:
|
||||
with open(p.pipfile_path, 'w') as f:
|
||||
f.write("""
|
||||
[scripts]
|
||||
printfoo = "python -c print('foo')"
|
||||
""")
|
||||
|
||||
c = p.pipenv('install')
|
||||
assert c.return_code == 0
|
||||
|
||||
c = p.pipenv('run printfoo')
|
||||
assert c.return_code == 0
|
||||
assert c.out == 'foo\n'
|
||||
assert c.err == ''
|
||||
|
||||
Reference in New Issue
Block a user