click Testing Click Applications

https://click.palletsprojects.com/en/7.x/testing/

import click

@click.command()
@click.argument('name')
def hello(name):
   click.echo('Hello %s!' % name)
from click.testing import CliRunner
from hello import hello

def test_hello_world():
  runner = CliRunner()
  result = runner.invoke(hello, ['Peter'])
  assert result.exit_code == 0
  assert result.output == 'Hello Peter!\n'
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章