Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用Python格式化测试输出_Python_Nose_Nosetests - Fatal编程技术网

用Python格式化测试输出

用Python格式化测试输出,python,nose,nosetests,Python,Nose,Nosetests,我正在使用nosetest,目录结构如下 repo package1 sub1 tests test1.py test2.py package2 sub2 tests test3.py test4.py package3 p

我正在使用nosetest,目录结构如下

repo
      package1
          sub1
             tests
                 test1.py
                 test2.py
      package2
          sub2
             tests
                 test3.py
                 test4.py
      package3
      package4
如果test1.py如下所示

class TestClass1(unittest.TestCase)
      def test_method1()

class TestClass2(unittest.TestCase)
      def test_method2()

class TestClass3(unittest.TestCase)
      def test_method3 
[Method name]  [modulename]. [ClassName] ... status
test_method1  (test1.TestClass1) ... ok
test_method2  (test1.TestClass2) ... ok
test_method3  (test1.TestClass3) ... ok
测试运行的输出如下所示

class TestClass1(unittest.TestCase)
      def test_method1()

class TestClass2(unittest.TestCase)
      def test_method2()

class TestClass3(unittest.TestCase)
      def test_method3 
[Method name]  [modulename]. [ClassName] ... status
test_method1  (test1.TestClass1) ... ok
test_method2  (test1.TestClass2) ... ok
test_method3  (test1.TestClass3) ... ok
我想将此输出格式化为如下内容

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

有什么帮助吗?谢谢。

您可以编写自己的nose插件来控制输出。有两个已经做到了这一点:nose_machineout和nose subunit。它们将是一个很好的起点