My code:
class TestSystemPromotion(unittest2.TestCase):
  @classmethod
  def setUpClass(self):
    ...
    self.setup_test_data()
    ..
  def test_something(self):
    ...
  def setup_test_data(self):
    ...
if __name__ == '__main__':
  unittest2.main()
Error which I'm getting is:
TypeError: unbound method setup_test_data() must be called with TestSystemPromotion
instance as first argument (got nothing instead)
                You can't call instance methods from class methods. Either consider using setUp instead, or make setup_test_data a class method too. Also, it's better if you called the argument cls instead of self to avoid the confusion - the first argument to the class method is the class, not the instance. The instance (self) doesn't exist at all when setUpClass is called.
class TestSystemPromotion(unittest2.TestCase):
  @classmethod
  def setUpClass(cls):
    cls.setup_test_data()
  @classmethod
  def setup_test_data(cls):
    ...
  def test_something(self):
    ...
Or:
class TestSystemPromotion(unittest2.TestCase):
  def setUp(self):
    self.setup_test_data()
  def setup_test_data(self):
    ...
  def test_something(self):
    ...
For better comprehension, you can think of it this way: cls == type(self)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With