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

How to use Fixture module level in python

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

Share

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

This article mainly introduces how to use the Fixture module level in python. It is very detailed and has a certain reference value. Friends who are interested must finish it!

Description

1. No matter how many classes are in the py file and how many methods are in the class, they can only be executed automatically once.

2. DefsetUpModule () is called automatically when the py file starts.

3. When the py file ends, deftearDownModule () is called automatically.

Example

Import unittest def setUpModule (): print ("setUpModule automatically called") def tearDownModule (): print ("tearDownModule automatically called") def my_sum (a B): return a + b class my_test1 (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) class my_test2 (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)) are all the contents of the article "how to use Fixture Module level in python" Thank you for reading! Hope to share the content to help you, more related 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