Katerina Romanchuk
unread,May 24, 2013, 3:01:05 PM5/24/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to nose-...@googlegroups.com
Hello! Guys, I need your help. I have problem - unittest/nose sent result in one stream, but I want to split stdout and stderr streams. TextTestRunner - is test runner class that displays results in textual form. It prints out the names of tests as they are run, errors as they occur, and a summary of the results at the end of the test run.
By default stream is stderr:
def __init__(self, stream=sys.stderr, descriptions=1, verbosity=1):
And tests result is look like:
Test 1 ... ok
Test 2 ... FAIL
Test 3 ... ok
Test4 ... FAIL
I can redirect stream in stdout:
And result is:
Test 1 ... ok
Test 2 ... FAIL
Test 3 ... ok
Test 5 ... FAIL
-------------------------------------------------------------------------------------------------------------------
I want have result look like this:
Test 1 ... ok
Test 2 ... FAIL
Test 3 ... ok
Test 4 ... FAIL
I have read a lot of solution for this problem in internet – but I don’t want to use some complicated decision and overwrite TextTestRunner.
If you know some easy way – please share knowledge with me.
Maybe is some way to do this via fixtures (setup and teardown methods)
-------------------------------------------------------------------------------------------------------------------
import unittest
class Tests(unittest.TestCase):
def setUp(self):
pass
def test_1(self):
"""Test 1"""
self.assertEquals(1, 1)
def test_2(self):
"""Test 2"""
self.assertEquals(1, 2)
def test_3(self):
"""Test 3"""
self.assertEquals(1, 1)
def test_4(self):
"""Test 4"""
self.assertEquals(1, 1)
def test_5(self):
"""Test 5"""
self.assertEquals(1, 7)
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromName('stream' )
#unittest.TextTestRunner(verbosity=2).run(suite)
unittest.TextTestRunner(verbosity=2, stream=sys.stdout).run(suite)