You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2009-12-10.02:42:22.502>created_at=<Date2009-12-10.02:20:55.156>labels= ['tests', 'type-bug', 'library', 'invalid']
title="Call to another class's constructor in unittest.TestCase.setUp returns the same instance multiple times"updated_at=<Date2009-12-10.02:46:30.978>user='https://bugs.python.org/awaltman'
Not sure if this is intended behavior. I have a baseClass I'm writing
tests for. My test architecture has an instance of this baseClass
assigned as a member of TestBaseClass(unittest.TestCase) in
TestBaseClass.setUp.
The problem occurs when tests in TestBaseClass modify state within the
member baseClass instance. I think there should be a fresh new instance
of baseClass for every test that gets run, but the old state from the
last test is still there.
Example code and output from Python 2.6.2 attached.
awaltmanmannequin
changed the title
Call to another class's constructor in unittest.TestCase.setUp returns the same instance
Call to another class's constructor in unittest.TestCase.setUp returns the same instance multiple times
Dec 10, 2009
Python 2.7a1+ (trunk:76725, Dec 9 2009, 09:26:36)
[GCC 4.4.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> classbaseClass(object):
... def__init__(self, testList=[]):
... self.testList = testList
... definsertItem(self):
... self.testList.append("testing from baseClass")
...
>>> a = baseClass()
>>> b = baseClass()
>>> del b
>>> a.insertItem()
>>> print a.testList
['testing from baseClass']
>>> b = baseClass()
>>> print b.testList
['testing from baseClass']
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: