Python Unit Test Automation



Download 1,71 Mb.
Pdf ko'rish
bet34/73
Sana31.12.2021
Hajmi1,71 Mb.
#213720
1   ...   30   31   32   33   34   35   36   37   ...   73
Bog'liq
2 5188215245394412341

Method
Checks That
assertEqual(a, b)
a == b
assertNotEqual(a, b)
a != b
assertTrue(x)
bool(x) is True
assertFalse(x)
bool(x) is False
assertIs(a, b)
a is b
assertIsNot(a, b)
a is not b
assertIsNone(x)
x is None
assertIsNotNone(x)
x is not None
assertIn(a, b)
a in b
assertNotIn(a, b)
a not in b
assertIsInstance(a, b)
isinstance(a, b)
assertNotIsInstance(a, b)
not isinstance(a, b)
 
Method
Checks That
assertAlmostEqual(a, b)
round(a-b, 7) == 0
assertNotAlmostEqual(a, b)
round(a-b, 7) != 0
assertGreater(a, b)
a > b
assertGreaterEqual(a, b)
a >= b
assertLess(a, b)
a < b
assertLessEqual(a, b)
a <= b
assertRegexpMatches(s, r)
r.search(s)
assertNotRegexpMatches(s, r)
not r.search(s)
assertItemsEqual(a, b)
sorted(a) == sorted(b)
assertDictContainsSubset(a, b)  all the key/value pairs in a exist in b
 


Chapter 3 

 Unittest
56
Method
Used to Compare
assertMultiLineEqual(a, b)
strings
assertSequenceEqual(a, b)
sequences
assertListEqual(a, b)
lists
assertTupleEqual(a, b)
tuples
assertSetEqual(a, b)
sets or frozensets
assertDictEqual(a, b)
dicts
All the assert methods listed in the previous tables are good enough for most of the 
programmers and testers for automating the tests.
Other Useful Methods
This section looks at a few useful methods that will help you debug and understand the 
flow of execution.
The id() and shortDescription() methods are very useful for debugging. id() 
returns the name of the method and shortDescription() returns the description of the 
method. Listing 
3-16
 shows an example.

Download 1,71 Mb.

Do'stlaringiz bilan baham:
1   ...   30   31   32   33   34   35   36   37   ...   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