- # Test escaping
- assert run_shell(['echo', 'test"&']) == '"test""&"\n'
- assert run_shell(['echo', '%CMDCMDLINE:~-1%&']) == '"%CMDCMDLINE:~-1%&"\n'
- assert run_shell(['echo', 'a\nb']) == '"a"\n"b"\n'
- assert run_shell(['echo', '"']) == '""""\n'
- assert run_shell(['echo', '\\']) == '\\\n'
- # Test if delayed expansion is disabled
- assert run_shell(['echo', '^!']) == '"^!"\n'
- assert run_shell('echo "^!"') == '"^!"\n'
+ for argument in tests:
+ if isinstance(argument, str):
+ expected = argument
+ else:
+ argument, expected = argument
+
+ args = [sys.executable, '-c', 'import sys; print(end=sys.argv[1])', argument, 'end']
+ assert run_shell(args) == expected
+ assert run_shell(shell_quote(args, shell=True)) == expected