Pyunit framework extending the classes of unittest

♀尐吖头ヾ 提交于 2019-12-13 02:50:04

问题


In Pyunit framework, I have question as below:

import unittest

class xyz(object):
    def test_fuc(self):
        print "test_fun"
        pass

class abc(unittest.Testcase, xyz):
    def setUp(self):
        print "setUp"

    def tearDown(self):
        print "tearDown"

    def test_one(self):
        print "test_one"
        pass

    def test_two(self):
        print "test_two"
        pass

Output:

test_one

test_two

test_fun

but I need output like below:

test_one

test_fun

test_two

test_fun

Please suggest, How do I do it?


回答1:


Unit tests (ie. unittest.TestCase methods) are supposed to be independant, and thus there is no point of running them twice.

If you want to do that, you probably should design your tests another way.



来源:https://stackoverflow.com/questions/22144990/pyunit-framework-extending-the-classes-of-unittest

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!