Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Pyhon Learning: assertion method

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

TestCase of the unittest framework provides the following assertion methods

method check version assertEqual(a,b)a==b

assertNotEqual(a,b)a!= b

assertTrue(x)bool(x) is True

assertFale(x)bool(x) is False

assertIs(a,b)a is b3.1assertNot(a,b)a is not b3.1assertNone(x)x is None3.1assertNotNoe(x)x is not None3.1assertIn(a,b)a is in b3.1assertNotIn(a,b)a is not in b3.1assertIsInstance(a,b)isinstance(a,b)3.2assertNotIsInstance(a,b)not isinstance(a,b)3.2

assertEqual(a,b,msg=None) Asserts whether the first argument and the second argument are equal, unequal Test failure, msg Optional parameter, used to define the information printed when the test fails

File isPrime

import unittest#to determine if it is a prime class IsPrime(): def __init__(self,number): self.number=number def isPrime(self): if self.number

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report