This commit is contained in:
Jev Kuznetsov
2025-09-15 09:09:40 +02:00
parent f6da3d9839
commit 27bb46e039
6 changed files with 33 additions and 75 deletions

View File

@@ -1,25 +1,24 @@
"""Tests for {{ cookiecutter.package_name }}."""
import pytest
from io import StringIO
import sys
from {{ cookiecutter.package_name }} import hello
from {{ cookiecutter.package_name }}.core import process_data, {{ cookiecutter.project_name.replace(' ', '').replace('-', '') }}
from {{ cookiecutter.package_name }}.core import say_hello
def test_hello():
"""Test hello function."""
result = hello()
assert "Hello from {{ cookiecutter.project_name }}" in result
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_process_data():
"""Test process_data function."""
result = process_data("test")
assert result == "Processed: test"
def test_main_class():
"""Test main class."""
instance = {{ cookiecutter.project_name.replace(' ', '').replace('-', '') }}("test")
result = instance.run()
assert "Running {{ cookiecutter.project_name }} with test" in result
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"