开发者

Pyunit setUpClass not running

Based on the documentation for PyUnit, I would expect the following code to run the test test_simple after calling setUpClass. However it doesn't seem to do that, I put a print statement inside setUpClass to verify this.

import unittest

class TestData(unittest.TestCase):

    def test_simple(self):
        pass

    @classmethod
    def setUpClass(cls):
        print "in setupUpClass"

if __name__ == "__main__":
    unittest.main()

From

http://docs.python.org/library/unittest.html

setUpClass()

A class method called be开发者_运维问答fore tests in an individual class run. setUpClass is called with the class as the only argument and must be decorated as a classmethod


It works for me. The documentation also mentions this was only added in Python 2.7 (3.2 for the 3.x releases). Do you have Python 2.7/3.2?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜