Files
python-cli-template/{{cookiecutter.project_slug}}/tests/test_{{cookiecutter.package_name}}.py
Jev Kuznetsov 27bb46e039 refactor
2025-09-15 09:09:40 +02:00

24 lines
642 B
Python

"""Tests for {{ cookiecutter.package_name }}."""
from io import StringIO
import sys
from {{ cookiecutter.package_name }}.core import say_hello
def test_say_hello():
"""Test say_hello function."""
captured_output = StringIO()
sys.stdout = captured_output
say_hello()
sys.stdout = sys.__stdout__
assert captured_output.getvalue() == "Hello, World!\n"
def test_say_hello_with_name():
"""Test say_hello function with custom name."""
captured_output = StringIO()
sys.stdout = captured_output
say_hello("Alice")
sys.stdout = sys.__stdout__
assert captured_output.getvalue() == "Hello, Alice!\n"