Python Unit Test Automation



Download 1,71 Mb.
Pdf ko'rish
bet62/73
Sana31.12.2021
Hajmi1,71 Mb.
#213720
1   ...   58   59   60   61   62   63   64   65   ...   73
Bog'liq
2 5188215245394412341

Listing 5-5.  test_module04.py
import pytest
@pytest.fixture()
def fixture01():
    print("\nIn fixture01()...")
def test_case01(fixture01):
    print("\nIn test_case01()...")
In Listing 
5-5
, fixture01() is the fixture function. It is because we are using the 
@pytest.fixture() decorator with that. test_case01() is a test function that uses 
fixture01(). For that, we are passing fixture01 as an argument to test_case01().
Here is the output:
============================= test session starts ======================
platform linux -- Python 3.4.2, pytest-3.0.4, py-1.4.31, pluggy-0.4.0 --  
/usr/bin/python3
cachedir: .cache
rootdir: /home/pi/book/code/chapter05/test, inifile:
collected 1 items
test_module04.py::test_case01
In fixture01()...
In test_case01()...
PASSED
========================== 1 passed in 0.04 seconds ====================


Chapter 5 

 pytest
94
As you can see, fixture01() is invoked before the test function test_case01(). You 
could also use the @pytest.mark.usefixtures() decorator, which achieves the same 
result. The code in Listing 
5-6
 is implemented with this decorator and it produces the 
same output as Listing 
5-5
.

Download 1,71 Mb.

Do'stlaringiz bilan baham:
1   ...   58   59   60   61   62   63   64   65   ...   73




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish