def generate_commands(self): commands = super().generate_commands() with NamedTemporaryFile(mode='w') as temp_file: temp_file.write('\n'.join(commands)) temp_file.flush() return stickytape.script( temp_file.name, add_python_paths=self.add_python_paths).splitlines()
def test_script_output(script_path, expected_output): result = stickytape.script(find_script(script_path)) with _temporary_script(result) as script_file_path: try: output = _shell.run([script_file_path]).output except: for index, line in enumerate(result.splitlines()): print((index + 1), line) raise assert_equal(expected_output, output)
def main(): args = _parse_args() output_file = _open_output(args) output = stickytape.script( args.script, add_python_modules=args.add_python_module, add_python_paths=args.add_python_path, python_binary=args.python_binary, ) output_file.write(output)
def test_script_output(script_path, expected_output, expected_modules=None, **kwargs): result = stickytape.script(find_script(script_path), **kwargs) if expected_modules is not None: actual_modules = set( re.findall(r"__stickytape_write_module\('([^']*)\.py'", result)) assert_equal(set(expected_modules), actual_modules) with _temporary_script(result) as script_file_path: try: if _is_windows(): command = ["py", script_file_path] else: command = [script_file_path] output = _shell.run(command).output.replace(b"\r\n", b"\n") except: for index, line in enumerate(result.splitlines()): print((index + 1), line) raise assert_equal(expected_output, output)
def main(): args = _parse_args() output_file = _open_output(args) output = stickytape.script( args.script, args.add_python_path, args.python_binary) output_file.write(output)