欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

Pytest安裝的詳細教程

本篇內(nèi)容主要講解“Pytest安裝的詳細教程”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學(xué)習(xí)“Pytest安裝的詳細教程”吧!

創(chuàng)新互聯(lián)建站是一家專業(yè)提供洪江管理區(qū)企業(yè)網(wǎng)站建設(shè),專注與做網(wǎng)站、成都網(wǎng)站建設(shè)、H5網(wǎng)站設(shè)計、小程序制作等業(yè)務(wù)。10年已為洪江管理區(qū)眾多企業(yè)、政府機構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)網(wǎng)站建設(shè)公司優(yōu)惠進行中。

 

 

1、安裝Pytest

命令行執(zhí)行 pip install pytest

2、快速開始

文件路徑

-helloworld

  -test_tmp.py

 

test_tmp.py

 

"""

文件以test_開始 或者 以 _test結(jié)尾的py  (test不區(qū)分大小寫)

 

"""

 

def test_l():

 

    """ test開始的函數(shù)會被當做測試用例直接執(zhí)行"""

    assert True

 

# content of test_sample.py

def inc(x):

    return x + 1

 

 

def test_answer():

    assert inc(3) == 5

 

執(zhí)行 pytest命令,可以自動搜索到test_tmp.py文件中的 2個test函數(shù)作為測試用例執(zhí)行。

 

========================================================= test session starts ==========================================================

platform win32 -- Python 3.7.5, pytest-5.3.5, py-1.8.1, pluggy-0.13.1

rootdir: C:\Users\zengy\Desktop\pytest-demo

collected 2 items                                                                                                                       

helloworld\test_tmp.py .F                                         [100%]

=============================================================== FAILURES ===============================================================_____________________________________________________________ test_answer ______________________________________________________________

 

    def test_answer():

>       assert inc(3) == 5

E       assert 4 == 5

E        +  where 4 = inc(3)

 

helloworld\tmp.py:17: AssertionError===================================================== 1 failed, 1 passed in 0.04s ======================================================

 

3、selenium test

from selenium import  webdriver

 

def test_login():

    driver = webdriver.Chrome()

    driver.get('http://39.107.96.138:3000/signin')

 driver.find_element_by_css_selector('#name').send_keys("testuser1")

 driver.find_element_by_css_selector('#pass').send_keys('123456')    driver.find_element_by_css_selector('input[value="登錄"]').click()

 

    #添加斷言

    # 1.登錄成功應(yīng)該跳轉(zhuǎn)到首頁

    current_url = driver.current_url

    assert current_url=="http://39.107.96.138:3000/","應(yīng)該跳轉(zhuǎn)到首頁"

 

   # 2.用戶名應(yīng)該為testuser1

   username = driver.find_element_by_css_selector('span

[class="user_name"]>a[class="dark"]').text

    assert username == "testuser1","登錄用戶名應(yīng)該為testuser1"

 

def test_register():

    pass

 

到此,相信大家對“Pytest安裝的詳細教程”有了更深的了解,不妨來實際操作一番吧!這里是創(chuàng)新互聯(lián)網(wǎng)站,更多相關(guān)內(nèi)容可以進入相關(guān)頻道進行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!

網(wǎng)站題目:Pytest安裝的詳細教程
文章出自:http://chinadenli.net/article4/gigooe.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制開發(fā)、網(wǎng)站收錄、定制網(wǎng)站、云服務(wù)器、網(wǎng)站設(shè)計、響應(yīng)式網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站建設(shè)