print success messages for asserts in python

前端 未结 5 1056
Happy的楠姐
Happy的楠姐 2020-12-19 14:04

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 cu

5条回答
  •  生来不讨喜
    2020-12-19 14:28

    This has been added to the pytest module as the hook pytest_assertion_pass

    in your conftest.py

    def pytest_assertion_pass(item, lineno, orig, expl):
    log.info("asserting that {}, {}, {}, {}".format(item, lineno, orig, expl))
    

    and in pytest.ini

    enable_assertion_pass_hook = true
    

提交回复
热议问题