问题
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