Skip to content
Myr

Added test for open_file

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 075a77b · Browse files · 1 file+21 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+21 added−0 removed

  • tests:+21 added−0 removed

1 file+21 added−0 removed

modified:tests/test_utils.py+21 added
120 unmodified lines
121 monkeypatch.setattr(click._termui_impl, 'isatty', lambda x: True)122 click.echo_via_pager('haha')123 out, err = capfd.readouterr()124 assert out == 'haha\n'125126127def test_open_file(runner):128 with runner.isolated_filesystem():129 with open('hello.txt', 'w') as f:130 f.write('Cool stuff')131132 @click.command()133 @click.argument('filename')134 def cli(filename):135 with click.open_file(filename) as f:136 click.echo(f.read())137 click.echo('meep')138139 result = runner.invoke(cli, ['hello.txt'])140 assert result.exception is None141 assert result.output == 'Cool stuff\nmeep\n'142143 result = runner.invoke(cli, ['-'], input='foobar')144 assert result.exception is None145 assert result.output == 'foobar\nmeep\n'