Function Test
By convention, the test method name needs to start with test_
.
For example, given this folder structure:
├── src
│ ├── __init__.py
│ ├── __pycache__
│ └── main.py
└── tests
├── __init__.py
├── __pycache__
└── main_test.py
Inside main_test.py
the content is:
import src.main as app
def test_addition():
actual = app.addition(1, 3)
assert actual == 1 + 3
With content of main.py
is:
from typing import *
def addition(a: int, b: int):
return a + b
To run this test, we can just simply call pytest
.