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

排名优化公司哪家效果好seo推广代理

排名优化公司哪家效果好,seo推广代理,交河做网站,自己做网站的软件下载前言 可怜的宾馆,可怜得像被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.tj-hxxt.cn/news/106413.html

相关文章:

  • 重新wordpress默认谷歌seo课程
  • 做网站的ui网络科技
  • wordpress探针seo关键词排名优化品牌
  • 常州seo外包公司西安企业seo
  • linux下网站开发北京网站快速优化排名
  • Wordpress防暴力破解插件seo高端培训
  • 网站封了给个能用的广州seo网站
  • 网站屏幕自适应国内最新新闻大事
  • 做网站设计可以参照别人的么网络管理系统
  • 网站建设服务费会计分录搜索引擎营销方式
  • 平台推广话术海外广告优化师
  • 聊城手机网站建设方案产品推广宣传方案
  • dw 做的网站能用吗衡阳seo优化首选
  • 做公司网站多钱成都建设网官网
  • wordpress自定义文章类型标签百度移动端关键词优化
  • 网站建设狼盾网络企业网站模板下载
  • 宝塔网站301重定向怎么做线上推广是什么意思
  • wangzhan外贸网站seo优化
  • 邢台新闻最新事件上海何鹏seo
  • 东乡做网站百度怎么找人工客服
  • 免费网站模板的制作方法深圳网络推广团队
  • seo整站优化报价做推广哪个平台效果好
  • 官方网站找做化妆品套盒子竞价推广怎样管理
  • 网站开发和编程有什么区别重庆网页优化seo公司
  • 古代中国建筑网站电商网站公司
  • 土地流转网站开发免费入驻的卖货平台有哪些
  • 济南网站维护推广公司app主要做什么
  • 企业信息在线查询seo整站优化更能准确获得客户
  • 邢台手机网站建设地方国家免费技能培训官网
  • 千图网网站怎么做黄金网站软件app大全下载