refactor
This commit is contained in:
@@ -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"
|
||||
Reference in New Issue
Block a user