diff --git a/pipenv/cmdparse.py b/pipenv/cmdparse.py index d7e349da..6240f0ba 100644 --- a/pipenv/cmdparse.py +++ b/pipenv/cmdparse.py @@ -35,7 +35,7 @@ class Script(object): def extend(self, extra_args): self._parts.extend(extra_args) - def cmdify(self, extra_args=None): + def cmdify(self): """Encode into a cmd-executable string. This re-implements CreateProcess's quoting logic to turn a list of @@ -54,8 +54,6 @@ class Script(object): See also: https://docs.python.org/3/library/subprocess.html#converting-argument-sequence """ - if extra_args: - self.extend(extra_args) return ' '.join( '"{0}"'.format(re.sub(r'(\\*)"', r'\1\1\\"', arg)) for arg in self._parts diff --git a/tests/test_cmdparse.py b/tests/test_cmdparse.py index 4e72ac5b..f54a276a 100644 --- a/tests/test_cmdparse.py +++ b/tests/test_cmdparse.py @@ -12,12 +12,20 @@ def test_parse(): assert script.args == ['-c', "print('hello')"], script +@pytest.mark.run +def test_extend(): + script = Script.parse(['python', '-c', "print('hello')"]) + script.extend(['--verbose']) + assert script.command == 'python' + assert script.args == ['-c', "print('hello')", "--verbose"], script + + @pytest.mark.run @pytest.mark.script def test_cmdify(): script = Script.parse(['python', '-c', "print('hello')"]) - cmd = script.cmdify(['--verbose']) - assert cmd == '"python" "-c" "print(\'hello\')" "--verbose"', script + cmd = script.cmdify() + assert cmd == '"python" "-c" "print(\'hello\')"', script @pytest.mark.run @@ -27,7 +35,7 @@ def test_cmdify_complex(): '"C:\\Program Files\\Python36\\python.exe" -c', """ "print(\'Double quote: \\\"\')" """.strip(), ])) - assert script.cmdify([]) == ' '.join([ + assert script.cmdify() == ' '.join([ '"C:\\Program Files\\Python36\\python.exe"', '"-c"', """ "print(\'Double quote: \\\"\')" """.strip(),