1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] print success messages for asserts in python

Discussão em 'Python' iniciado por Stack, Outubro 3, 2024 às 12:12.

  1. Stack

    Stack Membro Participativo

    I am using assert in python. Every time an assert fails I get the failure message which I would have put there to be printed. I was wondering if there is a way to print a custom success message when the assert condition passes?

    I am using py.test framework.

    for instance:

    assert self.clnt.stop_io()==1, "IO stop failed"


    for the above assert I get message "IO stop failed" if assert fails but I am looking to have "IO stop succeeded" if assert passes. something like this:

    assert self.clnt.stop_io()==1, "IO stop failed", "IO stop succeeded"

    Continue reading...

Compartilhe esta Página