示例#1
0
def test_str():
    calculator = BasicCalc()
    with pytest.raises(TypeError):
        calculator.divide("four", 2)




# thank god for stackoverlow
# Pating "pytest --show-capture" in terminal allowed me to see which tests would fail
示例#2
0
def test_man_fail():
    calculator = BasicCalc()
    with pytest.fail("I made this one fail."):
        calculator.add(2, 2)
示例#3
0
def test_zero_div():
    calculator = BasicCalc()
    result = calculator.divide(5, 0)
    assert result == "ZeroDivisionError"
示例#4
0
def test_will_fail():
    calculator = BasicCalc()
    result = calculator.add(2, 2)
    assert result == 5
示例#5
0
def test_divide():
    calculator = BasicCalc()
    result = calculator.divide(2, 2)
    assert result == 1
示例#6
0
def test_multiply():
    calculator = BasicCalc()
    result = calculator.multiply(2, 2)
    assert result == 4
示例#7
0
def test_subtract():
    calculator = BasicCalc()
    result = calculator.subtract(2, 2)
    assert result == 0
示例#8
0
def test_add():
    calculator = BasicCalc()
    result = calculator.add(2, 2)
    assert result == 4
示例#9
0
def test_str():
    calculator = BasicCalc()
    with pytest.raises(TypeError):
        calculator.divide("four", 2)