SKT
SKT

Reputation: 174

Call same function before every test case in python unittest framework

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

Upvotes: 2

Views: 2872

Answers (2)

Wooble
Wooble

Reputation: 89847

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

Upvotes: 1

Brian Agnew
Brian Agnew

Reputation: 272217

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.

Upvotes: 3

Related Questions