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

Example Analysis of python Fixture Class level

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Editor to share with you the python Fixture class-level example analysis, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Description

1. No matter how many methods there are in the class, a class automatically calls the function at the beginning and at the end.

2. The class level of fixture must be class method.

3. Divided into methods that are called automatically at the beginning or end of the class.

The method that is called automatically at the beginning of the @ classmethoddefsetUpClass (cls) class.

The method that is automatically called at the end of the @ clasmethoddeftearDownClass (cls) class.

Example

Import unittest def my_sum (a) B): return a + b class my_test (unittest.TestCase): @ classmethod def setUpClass (cls): print ("setupclass automatically called") @ classmethod def tearDownClass (cls): print ("teardownclass automatically called") 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)) above are all the contents of the article "sample Analysis at the python Fixture level" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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

Development

Wechat

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

12
Report