(
runner: CliRunner,
mycli_main,
contents: str,
args: list[str] | None = None,
)
| 170 | |
| 171 | |
| 172 | def invoke_click_batch( |
| 173 | runner: CliRunner, |
| 174 | mycli_main, |
| 175 | contents: str, |
| 176 | args: list[str] | None = None, |
| 177 | ): |
| 178 | with NamedTemporaryFile(prefix=TEMPFILE_PREFIX, mode='w', delete=False) as batch_file: |
| 179 | batch_file.write(contents) |
| 180 | batch_file.flush() |
| 181 | |
| 182 | try: |
| 183 | result = runner.invoke( |
| 184 | mycli_main.click_entrypoint, |
| 185 | args=['--batch', batch_file.name] + (args or []), |
| 186 | ) |
| 187 | return result, batch_file.name |
| 188 | finally: |
| 189 | if os.path.exists(batch_file.name): |
| 190 | os.remove(batch_file.name) |
| 191 | |
| 192 | |
| 193 | def write_batch_file(tmp_path: Path, contents: str) -> str: |
no test coverage detected