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 Shell のため先頭に ! が必要です。たとえば !pytest file_name.py のように実行します。
この演習はコースの一部です
