click-tester

A unittest.TestCase subclass which providesconvenience methods for testing click commands.


Keywords
click, testing, unittest, TestCase, pocoo
License
MIT
Install
pip install click-tester==1.0.0

Documentation

click-tester

Provides utilities for testing command line tools built with Pocoo Click library.

ClickRunnerTestCase

A unittest.TestCase subclass which provides convenience methods for testing click commands. Handles and displays errors, traceback information and command output.

import click
from click_tester import ClickRunnerTestCase


@click.command()
@click.option('--noun')
def hello(noun):
    print('hello ' + noun + '!')


class TestHelloCmd(ClickRunnerTestCase):
    def test_message(self):
        self.expect_invoke_success(my_command,
                                   ['--noun=world'],
                                   r'^hello world!')