[Python] How to finish a test using pytest earlier?

Discussão em 'Python' iniciado por Stack, Julho 30, 2025.

  1. Stack

    Stack Membro Participativo

    I need to test two functions inside another function. See the example below:

    def parent():
    a = A()
    b = B(a)
    c = C(b)
    d = D(c)
    e = E(d)
    f = F(e)
    g = G(f)
    h = H(g)
    return h


    I want to test only the interactions between A() and B(). The rest does not matter to me.

    I could split both functions into a second one, but it is not trivial. If I test the function parent(), I need to mock the functions C() to H().

    So, if the b variable reaches the expected value, I could end my test with a success.

    I don't see a suitable solution for this. Even if I use pytest.raises, it is more dedicated to test behaviors than partial tests.

    Continue reading...

Compartilhe esta Página