[BangPypers] issues using constructor in unittest
nitin.nitp at gmail.com
Mon Mar 14 10:30:01 CET 2011
I can't use setUp as this will be called every time for each test cases, I
thought of using setUpClass decorator but there i can define self.
self.x = 3
self.x += 1
I used this way as explained by you, still getting the same error.
On Mon, Mar 14, 2011 at 2:24 PM, Navin Kabra <navin.kabra at gmail.com> wrote:
> On Mon, Mar 14, 2011 at 1:56 PM, Nitin Kumar <nitin.nitp at gmail.com> wrote:
> > See below small example. I am trying to have one constructor for a class
> > with unittest inherited.
> Avoid overriding the constructor of TestCase. That is not recommended.
> > self.x = 3
> Put this is "setUp" instead of the constructor
> If you must do this, the correct way of doing it is:
> def __init__(self, *args, **kwargs):
> super(XMLSupport, self).__init__(*args, **kwargs)
> self.x = 3
> BangPypers mailing list
> BangPypers at python.org
More information about the BangPypers