Created
November 30, 2020 18:02
-
-
Save lewoudar/62fd2c5dbf5d052b15737e9e6e118a80 to your computer and use it in GitHub Desktop.
An example of how to test a cli application with click
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from click.testing import CliRunner | |
from scripts.pycat import cli | |
def test_pycat(tmp_path): | |
hello_file = tmp_path / 'hello.txt' | |
hello_file.write_text('hello world!') | |
runner = CliRunner() | |
result = runner.invoke(cli, [f'{hello_file.resolve()}']) | |
assert 0 == result.exit_code | |
assert 'hello world!\n' == result.output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment