test_skeleton.py 587 B

12345678910111213141516171819202122232425
  1. import pytest
  2. from rfidacd.skeleton import fib, main
  3. __author__ = "Thomas Verchow"
  4. __copyright__ = "Thomas Verchow"
  5. __license__ = "MIT"
  6. def test_fib():
  7. """API Tests"""
  8. assert fib(1) == 1
  9. assert fib(2) == 1
  10. assert fib(7) == 13
  11. with pytest.raises(AssertionError):
  12. fib(-10)
  13. def test_main(capsys):
  14. """CLI Tests"""
  15. # capsys is a pytest fixture that allows asserts agains stdout/stderr
  16. # https://docs.pytest.org/en/stable/capture.html
  17. main(["7"])
  18. captured = capsys.readouterr()
  19. assert "The 7-th Fibonacci number is 13" in captured.out