简体   繁体   中英

Call same function before every test case in python unittest framework

有没有办法在python unittest框架中的每个测试用例之前调用相同的函数?

Sounds like you should investigate setUp()

setUp()

Method called to prepare the test fixture. This is called immediately before calling the test method; any exception raised by this method will be considered an error rather than a test failure. The default implementation does nothing.

这就是unittest.TestCase子类的setUp方法的用途。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM