(runner)
| 335 | |
| 336 | |
| 337 | def test_file_option(runner): |
| 338 | @click.command() |
| 339 | @click.option("--file", type=click.File("w")) |
| 340 | def input(file): |
| 341 | file.write("Hello World!\n") |
| 342 | |
| 343 | @click.command() |
| 344 | @click.option("--file", type=click.File("r")) |
| 345 | def output(file): |
| 346 | click.echo(file.read()) |
| 347 | |
| 348 | with runner.isolated_filesystem(): |
| 349 | result_in = runner.invoke(input, ["--file=example.txt"]) |
| 350 | result_out = runner.invoke(output, ["--file=example.txt"]) |
| 351 | |
| 352 | assert not result_in.exception |
| 353 | assert result_in.output == "" |
| 354 | assert not result_out.exception |
| 355 | assert result_out.output == "Hello World!\n\n" |
| 356 | |
| 357 | |
| 358 | def test_file_lazy_mode(runner): |
nothing calls this directly
no test coverage detected