test_bugfixes.py

来自「mallet是自然语言处理、机器学习领域的一个开源项目。」· Python 代码 · 共 32 行

PY
32
字号
import unittestfrom test_support import run_suiteclass C:  def __str__(self):    raise Exception("E")  def __repr__(self):    raise Exception("S")class ExceptionHandling(unittest.TestCase):  def testBugFix1149372(self):    try:      c = C()      str(c)    except Exception, e:      assert e.args[0] == "E"      return    unittest.fail("if __str__ raises an exception, re-raise")def test_main():  test_suite = unittest.TestSuite()  test_loader = unittest.TestLoader()  def suite_add(case):    test_suite.addTest(test_loader.loadTestsFromTestCase(case))  suite_add(ExceptionHandling)  run_suite(test_suite)if __name__ == "__main__":  test_main()

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?