24 lines
642 B
Python
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" |