test/
-- test_add.py
src/
-- add.py
pytest
| def add(a,b): | |
| try: | |
| return a+b | |
| except Exception as e: | |
| print(e) | |
| raise(e) |
| import pytest | |
| from src.add import add | |
| ### test Functions #### | |
| def test_add(): | |
| assert add(5,5) == 10 | |
| def test_except(): | |
| with pytest.raises(Exception) as e_info: | |
| add(1,'test') | |
| def test_instance(): | |
| assert isinstance(add(5,5),int) |