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 before 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?