(runner)
| 657 | |
| 658 | |
| 659 | def test_open_file(runner): |
| 660 | @click.command() |
| 661 | @click.argument("filename") |
| 662 | def cli(filename): |
| 663 | with click.open_file(filename) as f: |
| 664 | click.echo(f.read()) |
| 665 | |
| 666 | click.echo("meep") |
| 667 | |
| 668 | with runner.isolated_filesystem(): |
| 669 | with open("hello.txt", "w") as f: |
| 670 | f.write("Cool stuff") |
| 671 | |
| 672 | result = runner.invoke(cli, ["hello.txt"]) |
| 673 | assert result.exception is None |
| 674 | assert result.output == "Cool stuff\nmeep\n" |
| 675 | |
| 676 | result = runner.invoke(cli, ["-"], input="foobar") |
| 677 | assert result.exception is None |
| 678 | assert result.output == "foobar\nmeep\n" |
| 679 | |
| 680 | |
| 681 | def test_open_file_pathlib_dash(runner): |
nothing calls this directly
no test coverage detected