How to run initialization code before tests when using Python's unittest module as a testrunner?

前端 未结 3 851
隐瞒了意图╮
隐瞒了意图╮ 2021-01-18 06:54

How can a user of a library run his own initialization code (setting debug levels of loggers for example) before running tests supplied with the library? Python\'s uni

3条回答
  •  粉色の甜心
    2021-01-18 07:27

    You could do the set-up work before calling unittest.main.

    Or you could subclass the test suite and run a class-level setup method.

    Or you could have the test setup incorporate a callback to a user-defined setup method.

提交回复
热议问题