程序员最近都爱上了这个网站  程序员们快来瞅瞅吧!  it98k网:it98k.com

本站消息

站长简介/公众号

  出租广告位,需要合作请联系站长

+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

暂无数据

在Python中格式化鼻子测试输出

发布于2019-10-14 21:05     阅读(1042)     评论(0)     点赞(7)     收藏(2)


我正在使用鼻子测试,目录结构如下

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

我想将此输出格式化为以下内容

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_machineout和鼻子子单元。对于您来说,它们将是一个很好的起点。



所属网站分类: 技术文章 > 问答

作者:黑洞官方问答小能手

链接:https://www.pythonheidong.com/blog/article/136818/c2c3427162e55cc14c8d/

来源:python黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

7 0
收藏该文
已收藏

评论内容:(最多支持255个字符)