当前位置: 首页 > news >正文

网站建设 服务内容建设苏州旅游网站的方案策划书

网站建设 服务内容,建设苏州旅游网站的方案策划书,招生网站制作,做外贸纱线用什么网站前言 可怜的宾馆,可怜得像被12月的冷雨淋湿的一条三只腿的黑狗。——《舞舞舞》 \;\\\;\\\; 目录 前言test_1或s_test格式非测试文件pytest.fixture()装饰器pytestselenium test_1或s_test格式 要么 test_前缀 在前,要么 _test后缀 在后! …

前言

可怜的宾馆,可怜得像被12月的冷雨淋湿的一条三只腿的黑狗。——《舞舞舞》

在这里插入图片描述


\;\\\;\\\;

目录

    • 前言
    • test_1或s_test格式
    • 非测试文件
    • @pytest.fixture()装饰器
    • pytest+selenium

test_1或s_test格式

要么 test_前缀 在前,要么 _test后缀 在后!

#test_1.py
def test_1():name='aa'assert 'bb'==namedef test_2():name='a'assert 'bcb'==namedef test_3():a = 1assert a == 2def test_4():a = 4assert a == 2assert 'a' in 'abc'assert 'a' not in 'abc'assert 'a' is not Trueassert 'a' is False

右击可以单独运行某个函数,看看哪个错了!

class TestTint:def test_5(self):a = 1assert a == 2def test_6(self):a = 1assert a == 2def test_7(self):a = 1assert a == 2

在这里插入图片描述

\;\\\;\\\;

非测试文件

如果是按pytest格式的文件名,但是内容不是测试的话,那么会出现(没有发现测试)

#test_calc.py
a = 1
b = 2
print(a + b)

在这里插入图片描述
\;\\\;\\\;

@pytest.fixture()装饰器

import pytest@pytest.fixture(scope='function')
def fixture1():print('前置步骤1')return 4@pytest.fixture(scope='function')
def fixture2():print('前置步骤2')return 2@pytest.fixture(scope='function',autouse=True)
def fixture3():print('前置步骤3')return 2def test_1(fixture1,fixture2):assert fixture1 == 2assert fixture2 == 2def test_2(fixture3):assert fixture3 == 2if __name__ == '__main__':pytest.main()

可以在测试函数的位置,右击运行test_1或test_2函数

\;\\\;\\\;

pytest+selenium

关于selenium使用的edge驱动器,版本要和电脑上装的edge版本一致!

pytest类要以Test为前缀

#test_f.py
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
import pytest# 前置方法
@pytest.fixture(scope='class')
def driver():driver = webdriver.Edge(executable_path=r"C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Scripts\msedgedriver.exe")#C:\ProgramData\anaconda3\Scripts\msedgedriver.exereturn driverclass TestSpider:# fixture函数作为形参def test_baidu(self, driver):driver.get('https://www.baidu.com/')title = driver.titleurl = driver.current_urltext = driver.find_element(By.CSS_SELECTOR, "a[href*='news.baidu.com']").textbutton = driver.find_element(By.ID, 'su').get_attribute('value')# 检测assert title == '百度一下,你就知道'assert url == 'https://www.baidu.com/'assert text == '新闻'assert button == '百度一下'# sleep(3)
# driver.close()if __name__ == '__main__':pytest.main()

运行命令 pytest test_f.py

http://www.yayakq.cn/news/751936/

相关文章:

  • 成都工程建设信息网站seo托管服务
  • 网站快速收录提交免费创建网站
  • 南京企业网站开发公司注册域名网站
  • 网站后台分类抖音seo怎么收费
  • zencart 团购网站沈阳世纪兴网站制作
  • 青海最好的网站建设公司网站开发和界面的区别
  • 企业网站建立网络虚拟社区时对于企业外贸网站的作用有哪些
  • 外贸网站建设工作室电子商务网站 注意
  • 网站后台登录怎么做的宁波公司核名网站
  • 做跟单员的话应该关注哪些网站南宁白帽seo技术
  • 智能logo设计网站wordpress 弹幕
  • 信用泰安网站wordpress 文章数
  • 柳州哪里有网站建设成都seo优化外包公司
  • 上海建设工程招投标在什么网站福田皇岗社区做网站
  • 移动互联网网站开发技术推广链接软件
  • 网站做优化效果怎么样如何用手机网站做淘宝客
  • wordpress怎么添加统计代码东莞seo推广
  • 精密科技东莞网站建设大连建设工程信息网登陆
  • 定制网站开发冬天里的白玫瑰搜索引擎排名竞价
  • 建设网站需要数据库备份网站网站建设网页设计
  • 建筑学生的网站做地方特产的网站
  • 门户网站开发源代码软件开发项目流程管理
  • 网站开发及后期维护室内装修设计软件vr
  • 做单页网站价格厦门网站建设教学
  • WordPress关站插件网站建设小公司生存
  • 专门做旅游的视频网站有哪些设计工作一般多少工资
  • 企业网站怎么做连接公众号里的电影网站怎么做的
  • 网站301是什么做牙网站
  • 大理石在哪些网站做宣传购买淘宝店铺在哪个平台
  • 专业做苗木的网站腾讯云快速搭建网站