Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use TestCase in python

Shulou Source: shulou.com Published: 2022-06-03 17:12:53 11月13日 Update

This article will explain in detail how to use TestCase in python. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Description

1. Import unittest module.

2. To implement a class, you must inherit the unittest.TestCase class.

3. Each method represents a test case, and the method name must start with test.

Example

Import unittest def my_sum (a, b): return a + b class my_test (unittest.TestCase): def test_001 (self): print (my_sum (5,6)) def test_002 (self): print (my_sum (0,3)) this article on "how to use TestCase in python" ends here. I hope the above content can be helpful to you, so that you can learn more knowledge. If you think the article is good, please share it for more people to see.

Tags: Articles methods more good practical representatives content examples articles modules knowledge reference help related testing Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Shulou Information Xiaomi vpn Linux