Mocking input/output


ex2/app.py
def calc():
    a = input("Type in a: ")
    b = input("Type in b: ")

    print("The result is:", add(int(a), int(b)))

def add(x, y):
    return x+y

if __name__ == '__main__':
    calc()

The test:


ex2/test_app.py
import app

def test_app():
    assert app.add(2, 3) == 5