def build_script(self, name, extra_args=None): # type: (str, Optional[List[str]]) -> Script try: script = Script.parse(self.parsed_pipfile["scripts"][name]) except KeyError: script = Script(name) if extra_args: script.extend(extra_args) return script
def test_cmdify(): script = Script('python', ['-c', "print('hello')"]) cmd = script.cmdify() assert cmd == '"python" "-c" "print(\'hello\')"', script
def test_cmdify_quote_if_carets(): """Ensure arguments are quoted if they contain carets. """ script = Script('foo^bar', ['baz^rex']) assert script.cmdify() == '"foo^bar" "baz^rex"', script
def test_extend(): script = Script('python', ['-c', "print('hello')"]) script.extend(['--verbose']) assert script.command == 'python' assert script.args == ['-c', "print('hello')", "--verbose"], script
def test_cmdify(): script = Script('python', ['-c', "print('hello world')"]) cmd = script.cmdify() assert cmd == 'python -c "print(\'hello world\')"', script