Can I perform multiple assertions in pytest?

后端 未结 5 1872
轻奢々
轻奢々 2020-12-25 15:24

I\'m using pytest for my selenium tests and wanted to know if it\'s possible to have multiple assertions in a single test?

I call a function that compares multiple v

5条回答
  •  攒了一身酷
    2020-12-25 15:40

    Here's an alternative approach called Delayed assert, It pretty much similar to what @Tryph has provided, and gives better stack trace.

    The delayed-assert package on PyPI implements this approach. See also the pr4bh4sh/python-delayed-assert repository on GitHub, or install from PyPI using:

    pip install delayed-assert
    

    You can use (possibly) any assertion library in combination with python-delayed-assert. Consider it more like a stack trace manager library rather than an assertion. Check this for example uses

    This is how the error stack trace looks,

提交回复
热议问题