Unable to run unittest's main function in ipython/jupyter notebook

前端 未结 3 1639
终归单人心
终归单人心 2021-02-02 16:17

I am giving an example which throws an error in ipython/jupyter notebook, but runs fine as an individual script.

import unittest

class Samples(unittest.TestCase         


        
3条回答
  •  死守一世寂寞
    2021-02-02 16:40

    We can try TestLoader to load test cases from TestCaseClass

    and attach those testcases to TextTestRunner then run it.

    import unittest
    suite = unittest.TestLoader().loadTestsFromTestCase(Samples)
    runner = unittest.TextTestRunner(verbosity=2)
    runner.run(suite)
    

提交回复
热议问题