PYTHONPython

test cli

real world projects / cli tool / tests

PYTHON
test_cli.py🐍
"""Tests for CLI commands."""

from click.testing import CliRunner
from devtools.main import cli


def test_cli_help():
    """Test CLI help runs."""
    runner = CliRunner()
    result = runner.invoke(cli, ['--help'])
    assert result.exit_code == 0
    assert 'DevTools' in result.output


def test_files_count():
    """Test files count command."""
    runner = CliRunner()
    result = runner.invoke(cli, ['files', 'count', '.'])
    assert result.exit_code == 0


def test_stats_summary():
    """Test stats summary command."""
    runner = CliRunner()
    with runner.isolated_filesystem():
        # Create test file
        with open('test.py', 'w') as f:
            f.write('print("hello")')
        
        result = runner.invoke(cli, ['stats', 'summary', '.'])
        assert result.exit_code == 0
PreviousNext