Python Unit Test Automation



Download 1,71 Mb.
Pdf ko'rish
bet38/73
Sana31.12.2021
Hajmi1,71 Mb.
#213720
1   ...   34   35   36   37   38   39   40   41   ...   73
Bog'liq
2 5188215245394412341

Listing 3-19.  test_module13.py
import unittest
class TestClass14(unittest.TestCase):
    def test_case01(self):
        raise Exception
The output of Listing 3-19 is as follows:
test_case01 (test_module13.TestClass14) ... ERROR
======================================================================
ERROR: test_case01 (test_module13.TestClass14)
----------------------------------------------------------------------
Traceback (most recent call last):
   File "/home/pi/book/code/chapter03/test/test_module13.py", line 6, in 
test_case01
    raise Exception
Exception
----------------------------------------------------------------------
Ran 1 test in 0.004s
FAILED (errors=1)
The failure message shown when the test fails due to an exception is different from 
when the test fails due to an assertion.


Chapter 3 

 Unittest
60
assertRaises()
You learned that the assert methods are used to check the test conditions. The 
assertRaises() method is used to check if the code block raises the exception 
mentioned in assertRaises(). If the code raises the exception then the test 
passes; otherwise, it fails. The code shown in Listing 
3-20
 demonstrates the usage of 
assertRaises() in detail.

Download 1,71 Mb.

Do'stlaringiz bilan baham:
1   ...   34   35   36   37   38   39   40   41   ...   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