pytest是python的一种单元测试框架(非自带,需要安装),与python自带的unitest测试框架相比,使用起来更加简洁、效率更高。总之,一句话,pytest优于unitest。

1.安装pytest  (其中-U 指升级原来已经安装的包)查看安装版本

查看安装版本  pip show pytest 或者 pytest --version

2.使用pytest的一个demo

# test_open_url.py
from selenium import webdriver def test_open_url():
try:
driver = webdriver.Chrome()
driver.get("http://www.baidu.com")
title = driver.title
print(driver.title) assert title == '百度一下,你就知道' # pytest允许使用python的标准assert语句进行断言处理 except AssertionError:
raise AssertionError("断言失败!")
driver.quit() def testbaidu():
driver = webdriver.Chrome()
driver.get("http://www.baidu.com")
title = driver.title
print(title)

方式一:进入命令行模式(Terminal):输入pytest 后回车

方式二:(方法二需要设置pycharm执行器为pytest(该执行器支持unitest的代码)pycharm中如何为项目设置默认执行器?

pytest1-Installation and Getting Started的更多相关文章

  1. mysql-5.6.34 Installation from Source code

    Took me a while to suffer from the first successful souce code installation of mysql-5.6.34. Just pu ...

  2. Create an offline installation of Visual Studio 2017 RC

    Create an offline installation of Visual Studio 2017 RC ‎2016‎年‎12‎月‎7‎日                             ...

  3. An error occurred during the installation of assembly 'Microsoft.VC90.CRT……的问题

    有一段时间没有用到AnkhSvn了,今天工作需要安装了一下.结果安装到一半就无法继续了,提示An error occurred during the installation of assembly ...

  4. "Installation failed !" in GUI but not in CLI (/usr/bin/winusb: line 78: 18265 Terminated )

    "Installation failed !" in GUI but not in CLI (/usr/bin/winusb: line 78: 18265 Terminated ...

  5. pymol installation

    # download (1) python wget https://www.python.org/ftp/python/2.7.9/python-2.7.9.amd64.msi (2) pymol ...

  6. 安卓真机调试 出现Installation error: INSTALL_FAILED_UPDATE_INCOMPATIBLE....

    [2016-08-20 14:38:39 - hybrid-android] Installation error: INSTALL_FAILED_UPDATE_INCOMPATIBLE[2016-0 ...

  7. The Installation and Compilation of OpenCASCADE

    OpenCASCADE的编译 The Installation and Compilation of OpenCASCADE eryar@163.com 一. 安装OpenCASCADE 可以从Ope ...

  8. kali 2.0 U盘安装错误Your installation cd-rom couldn't be mounted

    1.kali 2.0前天(2015.08.11)发布了.果断下载下来换掉本机的1.0版本. 2.用U盘安装的过程中,出现cd-rom无法挂载.提示错误Your installation CD-ROM ...

  9. linuxx virutal machine installation

    1. vmplayer download: https://my.vmware.com/web/vmware/free#desktop_end_user_computing/vmware_player ...

  10. linux apt-get install 错误: Package has no installation candidate

    sudo apt-get install vim 在安装vim时报如下错误: Error accoured: This may mean that the package is missing, ha ...

随机推荐

  1. TestNG(九) 异常测试

    package com.course.testng.suite; import org.testng.annotations.Test; public class ExpectedExeption { ...

  2. Qt无边框窗体-模拟模态窗体抖动效果

    目录 一.概述 二.效果展示 三.功能实现 四.相关文章 原文链接:Qt无边框窗体-模拟模态窗体抖动效果 一.概述 用Qt开发windows客户端界面确实是一大利器,兼顾性能的同时,速度相对来说也不错 ...

  3. spring中使用aop配置事务

    spring的事务配置有5种方式,这里记录其中的一种:基于tx/aop声明式事务配置 在之前spring aop介绍和示例这篇所附代码的基础上进行测试 一.添加save方法 1.在testDao类里添 ...

  4. Linux mint 启动文本模式(不启动图形界面)

    Linux Mint 系统用了很久,很顺手,赞一个! 有一天想同时运行多个虚拟机linux系统做实验,想着只启动文本模式可以省点内存资源,结果试了多种方法都不成功,网上现有针对Ubuntu原版和Cen ...

  5. linux分析利刃之sar命令详解

    一.sar的概述 在我使用的众多linux分析工具中,sar是一个非常全面的一个分析工具,可以比较瑞士军刀,对文件的读写,系统调用的使用情况,磁盘IO,CPU相关使用情况,内存使用情况,进程活动等都可 ...

  6. java程序猿如何练习java版的易筋经?

    故事背景 电视剧<天龙八部>中,阿朱易容后进入少林寺偷走了<易筋经>,她一直想把这本书送给乔峰.耿直的乔峰觉得此书来历不正,不肯接受.几番波折,这本书最后落到聚贤庄庄主游坦之手 ...

  7. 向net core 3.0进击——Swagger的改变

    目录 前言 引入 测试 小结 前言 十一小长假在不知不觉间可都没了,在这个小尾巴的空隙,把这两天鼓捣的net core 3.0升级过程记录一下,首先还是根据之前的顺序一个个补充进来,先从Swagger ...

  8. apache中通过mod_rewrite实现伪静态页面的方法

    rewrite规则学习 我们新建一个.htaccess文件之后,就在里面写入以下内容: RewriteEngine on #rewriteengine为重写引擎开关on为开启off为关闭 Rewrit ...

  9. 同时支持EF+Dapper的混合仓储,助你快速搭建数据访问层

    背景 17年开始,公司开始向DotNet Core转型,面对ORM工具的选型,当时围绕Dapper和EF发生了激烈的讨论.项目团队更加关注快速交付,他们主张使用EF这种能快速开发的ORM工具:而在线业 ...

  10. 开发电商平台用PHP语言和JAVA语言有什么区别?哪种语言更好?

    现在很多行业都通过电子商务拓展业务,所以商城系统开发成为很多企业的刚性需求.一般有一点技术基础的客户应该知道目前商城系统开发主流语言有两个,PHP和Java.那么很多客户朋友会纠结是选择哪个语言开发好 ...