Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Formatting nosetest output in Python

I am using the nosetests and have my directory structure as follows

repo
      package1
          sub1
             tests
                 test1.py
                 test2.py
      package2
          sub2
             tests
                 test3.py
                 test4.py
      package3
      package4

and if the test1.py is as below

class TestClass1(unittest.TestCase)
      def test_method1()

class TestClass2(unittest.TestCase)
      def test_method2()

class TestClass3(unittest.TestCase)
      def test_method3 

The output of the nosetests run is as below

[Method name]  [modulename]. [ClassName] ... status
test_method1  (test1.TestClass1) ... ok
test_method2  (test1.TestClass2) ... ok
test_method3  (test1.TestClass3) ... ok

I would like to format this output to something like below

repo.package1.sub1 [package]                             SUCCESS
    test1.py [unit test file]                                SUCCESS
        TestClass1.test_method1 [unit test]                  SUCCESS
        TestClass2.test_method2 [unit test]                  SUCCESS
        TestClass3.test_method3 [unit test]                  SUCCESS

Any help? Thanks.

like image 490
vinay polisetti Avatar asked Sep 28 '12 10:09

vinay polisetti


1 Answers

You can write your own nose plug in to control the output. There are two on this page which already do that: nose_machineout and nose-subunit. They would be a good starting point for you to look at.

like image 146
grieve Avatar answered Oct 25 '22 18:10

grieve