pytest로 코드 테스트하기
test.py의 다음 테스트 코드를 살펴보세요.
def test_mortgage_calculator_example():
'''
Test an example case for the mortgage calculator
'''
# Instantiate a mortgage calculator
mortgage_calculator = calculators.MortgageCalculator(200000,
0.065,
30)
# Calculate the monthly payment
monthly_payment = mortgage_calculator.monthly_payment
# Run a test
assert monthly_payment == 1264.14
이 파일을 pytest로 검사하면 통과할까요? 콘솔에서 Pytest를 사용하려면 IPython 셸 환경이므로 !로 시작해야 합니다. 예: !pytest file_name.py.
이 연습은 강의의 일부입니다
