Python Unit Test Automation



Download 1,71 Mb.
Pdf ko'rish
bet50/73
Sana31.12.2021
Hajmi1,71 Mb.
#213720
1   ...   46   47   48   49   50   51   52   53   ...   73
Bog'liq
2 5188215245394412341

Listing 4-8.  test_module06.py
from nose.tools import ok_, eq_
def test_case01():
    ok_(2+2 == 4, msg="Test Case Failure...")
def test_case02():
    eq_(2+2, 4, msg="Test Case Failure...")
def test_case03():
    ok_(2+2 == 5, msg="Test Case Failure...")
def test_case04():
    eq_(2+2, 5, msg="Test Case Failure...")
The following shows the output of the code in Listing 
4-8
.
In setUpPackage()...
test.test_module06.test_case01 ... ok
test.test_module06.test_case02 ... ok
test.test_module06.test_case03 ... FAIL
test.test_module06.test_case04 ... FAIL
In tearDownPackage()...


Chapter 4 

 nose and nose2
78
======================================================================
FAIL: test.test_module06.test_case03
----------------------------------------------------------------------
Traceback (most recent call last):
   File "/usr/local/lib/python3.4/dist-packages/nose/case.py", line 198,  
in runTest
    self.test(*self.arg)
   File "/home/pi/book/code/chapter04/test/test_module06.py", line 13,  
in test_case03
    ok_(2+2 == 5, msg="Test Case Failure...")
AssertionError: Test Case Failure...
======================================================================
FAIL: test.test_module06.test_case04
----------------------------------------------------------------------
Traceback (most recent call last):
   File "/usr/local/lib/python3.4/dist-packages/nose/case.py", line 198,  
in runTest
    self.test(*self.arg)
   File "/home/pi/book/code/chapter04/test/test_module06.py", line 17,  
in test_case04
    eq_(2+2, 5, msg="Test Case Failure...")
AssertionError: Test Case Failure...
----------------------------------------------------------------------
Ran 4 tests in 0.015s
FAILED (failures=2)
The @raises() Decorator
When you use raises decorator before the test, it must raise one of the exceptions 
mentioned in the list of exceptions associated with the @raises() decorator. Listing 
4-9
 
demonstrates this idea.

Download 1,71 Mb.

Do'stlaringiz bilan baham:
1   ...   46   47   48   49   50   51   52   53   ...   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