In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.