[BangPypers] issues using constructor in unittest

Navin Kabra navin.kabra at gmail.com
Mon Mar 14 11:57:50 CET 2011


On Mon, Mar 14, 2011 at 3:00 PM, Nitin Kumar <nitin.nitp at gmail.com> wrote:

> I used this way as explained by you, still getting the same error.
>

What version of python are you using?

Here is the code I tried and it works fine with python 2.6.5 and  unittest2
0.5.1.

#!/usr/bin/env python

import unittest2

class TestIt(unittest2.TestCase):
    def __init__(self, *args, **kwargs):
        super(TestIt, self).__init__(*args, **kwargs)
        self.x = 3

    def testit(self):
        self.assertEqual(self.x, 3)
        self.assertNotEqual(self.x, 2)

if __name__ == '__main__':
    unittest2.main()


More information about the BangPypers mailing list