Unittest output in IPython

I have a script to test a module using unittest. When I run the script using the python console I get the output:

test_equal (__main__.TestOutcome) ... ok test_win_amount (__main__.TestOutcome) ... ok ---------------------------------------------------------------------- Ran 2 tests in 0.000s OK 

But when I run the script using the IPython console, I do not get any output.

I use the following to run a script,

 suite = unittest.TestLoader().loadTestsFromTestCase(TestOutcome) unittest.TextTestRunner(verbosity=2).run(suite) 

Any ideas if this could be related to IPython settings?

+6
source share
1 answer

Calling TextTestRunner with the stream parameter will make it work in IPython. This is how I run the tests:

 suite = unittest.TestLoader().loadTestsFromTestCase( MyTest ) unittest.TextTestRunner(verbosity=1,stream=sys.stderr).run( suite ) 
+8
source

Source: https://habr.com/ru/post/951986/


All Articles