def METHOD_NAME(self) -> None:
    bin = "/layer-test-binary"
    # Test no-op rewriting
    cmd = [bin, "foo", "--bar", "beep", "--baz", "-xack", "7", "9"]
    # pyre-fixme[16]: `Tuple` has no attribute `__enter__`.
    with rewrite_testpilot_python_cmd(cmd, next_fd=1337) as cmd_and_fd:
        self.assertEqual((cmd, []), cmd_and_fd)
    for rewritten_opt in ("--output", "--list-tests"):
        with temp_dir() as td:
            tmp = td / "foo.json"
            self.assertFalse(os.path.exists(tmp))  # Will be created
            prefix = ["--zap=3", "--ou", "boo", "--ou=3"]
            suffix = ["garr", "-abc", "-gh", "-d", '--e"f']
            with rewrite_testpilot_python_cmd(
                [bin, *prefix, f"{rewritten_opt}={tmp}", *suffix],
                next_fd=37,
            ) as (new_cmd, fds_to_forward):
                (fd_to_forward,) = fds_to_forward
                self.assertIsInstance(fd_to_forward, int)
                # The last argument deliberately requires shell quoting.
                self.assertEqual(
                    [
                        "/bin/bash",
                        "-c",
                        " ".join(
                            [
                                "exec",
                                bin,
                                rewritten_opt,
                                ">(cat >&37)",
                                *prefix,
                                *suffix[:-1],
                                """'--e"f'""",
                            ]
                        ),
                    ],
                    new_cmd,
                )
                self.assertTrue(os.path.exists(tmp))  # Was created