Python
-
【iTestCat】分支if…else…(Python3自动化教程)
1)if 如果if语句判断是True,就把缩进的两行print语句执行了,否则,什么也不做。
1234#-*- coding:utf-8 -*-num = input('Please input your number: ')if num == '1':print('itestcat')2)if…else… 如果if判断是False,不要执行if的内容,去把else执行了:
123456#-*- coding:utf-8 -*-num =input('Please input your number: ')if num=='1':print('itestcat')else:print('itestcat.com')3)if…elif…else elif是else…
-
【iTestCat】Python2\Python3输入输出及区别(Python3自动化教程)
1.1输出 python2中输出可以使用空格或者小括号。 示例: print "hello itestcat"或者 print("hello itestcat") python3中输出只能小括号。 示例: print("hello itestcat") 1.2 输入 Python2中,…
-
【iTestCat】windows下安装配置python3、pip
第1步:安装Python 根据下面的地址,直接一键安装,路径选择C:\Python36,方便后面查找。 下载地址:https://www.python.org/ftp/python/3.6.3/python-3.6.3-amd64.exe 然后设置Python的环境变量, Path:“C:\Python36” 1).点击【我的电脑】->【属性】->…
-
【iTestCat】pytest测试框架-main()函数执行测试用例
第一种:默认执行: if __name__ == ‘__main__’: pytest.main() main() 默认执行了当前文件所在的目录下的所有测试文件。 第二种:执行指定测试文件: 运行指定测试文件: if __name__ == ‘__main__’: pytest.main(“-q t…
-
【iTestCat】pytest测试框架-丰富的插件
安装插件,使用pip可以轻松完成: 安装:pip install pytest-名字 卸载:pip uninstall pytest-名字 一些流行的插件 pytest-html:生成html测试报告 pytest-Django:编写测试Django的应用程序,使用pytest整合。 pytest-twisted:编写测试twisted的应用程序。 pyte…
-
【iTestCat】pytest测试框架-一个简单的例子
创建itestcat.py文件
1234def inc(x):? return x + 1def test_answer():? assert inc(3) == 5执行py文件 进入终端输入py.test itestcat.py 运行多个测试 pytest运行当前目录及其子目录中所有文件test _ * .py或* _test.py,这是pytest遵循的规则。
-
【iTestCat】Pytest测试框架-安装
1.什么是pytest? pytest是一款python自动化测试框架,市面上常用的测试框架还有unittest(自带),nose。 支持python2和python3。 2.安装pytest 如果你已经安装pip,可以直接在终端输入(如果你不知道怎么安装pip请看selenium+python3搭建环境) pip install pytest 你也可以直接…