首页 > 其他分享 >pytest断言

pytest断言

时间:2023-03-16 13:00:12浏览次数:34  
标签:william 断言 包含 assert pytest test

pytest断言

  1、使用 ==、!=、<、>、>=、<=

  2、使用in和not in来测试包含或不包含

  3、使用true或false

class TestAssert:
    def test_assert(self):
        # ==,!=,>,<,>=,<=
        assert 'william' == 'william'
        assert 'william-a' != 'william-b'
        assert 0 < 1
        assert 2 > 1
        assert 3 <= 7 - 2
        assert 4 >= 1 + 2
        # 包含和不包含
        assert 'william' in 'william-UI_test'
        assert 'william' not in 'UI_test'
        # true和false
        assert 1
        assert 9==10 is True
        assert not False
        assert not True

 

标签:william,断言,包含,assert,pytest,test
From: https://www.cnblogs.com/purewhite/p/17222144.html

相关文章

  • pytest测试框架
    1、pytest安装与依赖依赖pytestrequires:Python3.7+orPyPy3.安装#安装pytest:pipinstallpytest#升级pytest pipinstall-Upytest#查看pytest版本pytest--......
  • JSON断言和响应断言的使用
    在http请求下建立一个json断言的设置  2.响应断言的设置 ......
  • Pytest - 分布式执行插件:xdist
    pytest-xdist分布式测试插件安装$pipinstallpytest-xdist测试代码准备classTest:deftest_sleep_2(self):sleep(2)assertFalse......
  • pytest--创建临时目录和文件
    前言在平常测试当中,可能会有一些临时数据,比如输出信息、token、临时密码等数据需要临时保存和读取。那么pytest也提供了一个fixture来支持这种情况。能够创建临时目录文......
  • pytest---创建临时文件来存储测试数据(tmpdir)
    前言在跑自动化测试中,测试过程中会用到一些测试数据,其中这些测试数据包括临时测试数据和常用到的数据,经常用到的数据,我们可以通过Excel或者yaml文件的方式进行存储,那......
  • python+playwright 学习-25 expect 常用的断言方法
    前言playwright提供了一个expect方法用于断言expect使用断言描述expect(locator).to_be_checked()Checkboxischeckedexpect(locator).to_be_disable......
  • httprunner3.X validate 断言
    1、validate可以支持的校验方式项目缩写功能equal“eq”,“equals”,“equal”相等less_than“lt”,“less_than”小于less_or_equals“le”,“l......
  • pytest some
    importparamikoimporttimeimportallurefromselfimportselfimportpytestclassSSLConnection:defrun(self,ssh,command):stdin,stdout,s......
  • pytest - 结合 allure 报告
    修改报告内fixture方法名展示@allure.title("我是fixture")defsetup_session(autouse=True,scope="session")print("setup")yieldprint("teardown")......
  • java断言机制(assert)
    java断言机制(assert)概述断言使用的时候不是很多,测试时会使用,springboot中也有使用,总的来说断言还是要慎重。在Java中,同样也有assert关键字,表示断言在Java中,assert关键......