mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
15c7308ca9
I chose to make Script.parse to always operate in POSIX mode so it is much easier to write commands compatible on all platforms. Script.cmdify is the important part on Windows. It ensures the argument line is always escaped and joined properly on Windows, not just for the subset that works both under POSIX and Windows (as is the case of shlex.escape).
28 lines
797 B
Python
28 lines
797 B
Python
import textwrap
|
|
|
|
from pipenv.cmdparse import Script
|
|
|
|
|
|
def test_parse():
|
|
script = Script.parse(['python', '-c', "print('hello')"])
|
|
assert script.command == 'python'
|
|
assert script.args == ['-c', "print('hello')"], script
|
|
|
|
|
|
def test_cmdify():
|
|
script = Script.parse(['python', '-c', "print('hello')"])
|
|
cmd = script.cmdify(['--verbose'])
|
|
assert cmd == '"python" "-c" "print(\'hello\')" "--verbose"', script
|
|
|
|
|
|
def test_cmdify_complex():
|
|
script = Script.parse(' '.join([
|
|
'"C:\\Program Files\\Python36\\python.exe" -c',
|
|
""" "print(\'Double quote: \\\"\')" """.strip(),
|
|
]))
|
|
assert script.cmdify([]) == ' '.join([
|
|
'"C:\\Program Files\\Python36\\python.exe"',
|
|
'"-c"',
|
|
""" "print(\'Double quote: \\\"\')" """.strip(),
|
|
]), script
|