In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you how to use setup and teardown in python. I hope you will get something after reading this article. Let's discuss it together.
Description
1. Setup/teardown: each method will be executed once, both inside and outside the class.
2. Setup: the method is executed before it is run, indicating the precondition.
It must be executed once before each use case is executed.
3. Teardown: the method cannot be executed until it is run, which means that the resource is released.
It is executed once after each use case is executed.
Example
# file_name: test_setup.pyimport pytestdef setup (): print ("... out-of-class setup...") def test_create (): print ("out-of-class test_create") def test_view (): print ("out-of-class test_view") class TestSetupClass: def setup (self): print ("... in-class setup...") Def test_create (self): print ("intra-class test_create") def test_view (self): print ("intra-class test_view") def teardown (self): print (". In-class teardown... ") def teardown (): print ("... "out-of-class teardown...") if _ _ name__ = ='_ main__': pytest.main (['- vs', 'test_setup.py']) after reading this article, I believe you have some understanding of "how to use setup and teardown in python". If you want to know more about it, welcome to follow the industry information channel, thank you for reading!
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.