1. Učit se
  2. /
  3. Projekty
  4. /
  5. Případová studie: Tvorba softwaru v Pythonu

Connected

cvičení

Otestuj kód pomocí pytest

Prohlédni si následující testovací kód v souboru 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

Projde tento soubor kontrolou pomocí pytest? Aby šlo Pytest spustit v konzoli, je potřeba začít s !, například !pytest file_name.py, protože se jedná o IPython Shell.

Pokyny

50 XP

Možné odpovědi