<pre><code>import unittest
class TestTemplate(unittest.TestCase):
@classmethod
def setUpClass(self):
self.result = 'error'
print "setUpClass"
@classmethod
def tearDownClass(self):
print "The value of result is, ",self.result
if self.result == 'ok':
print "it is working"
print "The value of cls result is : ", self.result
print "TearDownClass"
class MyTest(TestTemplate):
def test_method_one(self):
self.result = 'ok'
print self.result
if __name__ == '__main__':
unittest.main()
</code></pre>
<p>在<code>tearDownClass</code>中自我结果是<code>error</code>,但它应该是{<cd3>},因为我在方法中更改了它?有什么解决办法吗?在</p>