1、pytest断言assert
(1)基本使用
assert断言的使用比较简单,只需assert + 逻辑判断语句即可
# coding: utf-8
import pytest
class Test_Case:
def test_case1(self):
assert 1 == 1
if __name__ == '__main__':
pytest.main(['./test_demo1.py::Test_Case::test_case1', '-s'])
输出结果
此外,我们还可以使用其他的判断语句,例如
# coding: utf-8
import pytest
class Test_Case:
def test_case1(self):
a = 2
b = 1
assert a > b
def test_case2(self):
a = 'Hello World'
b = 'ass'
assert b in a
def check_return(self):
return True
def test_case3(self):
assert self.check_return()
if __n