Python Unit Test Automation



Download 1,71 Mb.
Pdf ko'rish
bet25/73
Sana31.12.2021
Hajmi1,71 Mb.
#213720
1   ...   21   22   23   24   25   26   27   28   ...   73
Bog'liq
2 5188215245394412341

Listing 3-6.  test_module06.py
import unittest
class TestClass07(unittest.TestCase):
        def test_case01(self):
                self.assertTrue("PYTHON".isupper())
                print("\nIn test_case01()")


Chapter 3 

 Unittest
40
If you try to run it the usual way, with python3 test_module06.py, you do not get 
output in the console, as it does not have the if __name__=='__main__' and unittest.
main() statements in it. Even running in verbose mode with python3 test_module06.py 
-v does not yield any output in the console.
The only way to run this module is to use the Python interpreter with the -m 
unittest option and the module name, as follows:
python -m unittest test_module06
The output is as follows:
In test_case01()
.
----------------------------------------------------------------------
Ran 1 test in 0.002s
OK
Note that you do not need to have .py after the module name as you did earlier. You 
can also enable verbosity with the -v options, as follows:
python -m unittest test_module06 -v
The verbose output is as follows:
test_case01 (test_module06.TestClass07) ...
In test_case01()
ok
----------------------------------------------------------------------
Ran 1 test in 0.002s
OK
We will use this same method throughout the chapter to run test modules. In later 
sections of this chapter, you will learn more about this method. For now, run all the 
previous code examples with this method of execution as an exercise.
Controlling the Granularity of Test Execution
You learned how to run a test module using the -m unittest option. You can also run 
individual test classes and test cases using this option.
Consider the earlier example of test_module04.py again, shown in Listing 
3-7
.

Download 1,71 Mb.

Do'stlaringiz bilan baham:
1   ...   21   22   23   24   25   26   27   28   ...   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