Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of Fixture method-level Operation in python

Shulou Source: shulou.com Published: 2022-06-03 17:39:05 10月02日 Update

Editor to share with you the example analysis of Fixture method-level operation in python. I hope you will get something after reading this article. Let's discuss it together.

Description

1. Define TestCase, that is, the method in the class where the test case is located.

2. DefsetUp is called automatically before the test case is executed.

3. DeftearDown is called automatically when the test case is executed.

If there are multiple test cases in TestCase, setUp and tearDown will be called automatically multiple times.

Example

The content of mytest.py is modified as follows:

Import unittest def my_sum (a, b): return a + b class my_test (unittest.TestCase): def setUp (self): print ("setup is automatically called") def tearDown (self): print ("teardown is automatically called") def test_001 (self): print (my_sum (5,6) def test_002 (self): print (my_sum (0) 3) after reading this article I believe you have a certain understanding of "sample analysis of Fixture method-level operations in python". If you want to know more about it, please follow the industry information channel. Thank you for reading!

Tags: Tests methods examples analysis articles content multiple finished examples location more knowledge industry information information channels channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Redmi MySQL Linux Huawei