Is there any way to call same function before every testcase in python unittest framework?

有帮助吗?

解决方案

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.

其他提示

This is what the setUp method of your unittest.TestCase subclass is for.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top