Python unittest - opposite of assertRaises?

前端 未结 10 673
甜味超标
甜味超标 2020-12-04 05:36

I want to write a test to establish that an Exception is not raised in a given circumstance.

It\'s straightforward to test if an Exception is raise

10条回答
  •  鱼传尺愫
    2020-12-04 05:56

    def run_test(self):
        try:
            myFunc()
        except ExceptionType:
            self.fail("myFunc() raised ExceptionType unexpectedly!")
    

提交回复
热议问题