Initial commit
This commit is contained in:
25
tests/test_skeleton.py
Normal file
25
tests/test_skeleton.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import pytest
|
||||
|
||||
from cristallina.skeleton import fib, main
|
||||
|
||||
__author__ = "Alexander Steppke"
|
||||
__copyright__ = "Alexander Steppke"
|
||||
__license__ = "MIT"
|
||||
|
||||
|
||||
def test_fib():
|
||||
"""API Tests"""
|
||||
assert fib(1) == 1
|
||||
assert fib(2) == 1
|
||||
assert fib(7) == 13
|
||||
with pytest.raises(AssertionError):
|
||||
fib(-10)
|
||||
|
||||
|
||||
def test_main(capsys):
|
||||
"""CLI Tests"""
|
||||
# capsys is a pytest fixture that allows asserts against stdout/stderr
|
||||
# https://docs.pytest.org/en/stable/capture.html
|
||||
main(["7"])
|
||||
captured = capsys.readouterr()
|
||||
assert "The 7-th Fibonacci number is 13" in captured.out
|
||||
Reference in New Issue
Block a user