Can I perform multiple assertions in pytest?

后端 未结 5 1873
轻奢々
轻奢々 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:43

    yet another library is available by the author of the 2017 Pragmatic book on pytest, Brian Okken. https://pythontesting.net/books/pytest/ https://github.com/okken/pytest-check

    import pytest_check as check
    
    def test_example():
        a = 1
        b = 2
        c = [2, 4, 6]
        check.greater(a, b)
        check.less_equal(b, a)
        check.is_in(a, c, "Is 1 in the list")
        check.is_not_in(b, c, "make sure 2 isn't in list")
    

提交回复
热议问题