[Python] Assertion Error vs Assert in pytest, why do I get different error messages when...

Discussão em 'Python' iniciado por Stack, Março 19, 2025.

  1. Stack

    Stack Membro Participativo

    I have following dummy test cases in python and I am trying to have a better understanding of the error messages produced by pytest.

    when I run these 4 test cases I get the following errors

    FAILED test_assert_false_2 - AssertionError: assert 'abc' in 'defab'

    FAILED test_1 - assert 0

    FAILED test_2 - assert 3 < 2

    FAILED test_3 - assert 1 > 2


    why do I get AssertionError in first case and just assert in following cases

    def test_assert_false_2():
    assert 'abc' in 'defab'

    def test_1():
    assert 1
    assert 0

    def test_2():
    assert 3 < 2

    def test_3():
    a = 2
    b = 1
    assert b > a

    Continue reading...

Compartilhe esta Página