[issue7465] Call to another class's constructor in unittest.TestCase.setUp returns the same instance multiple times
Changes by Aaron Altman aa...@tomorrowsfunction.com: -- 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 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7465 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7465] Call to another class's constructor in unittest.TestCase.setUp returns the same instance multiple times
R. David Murray rdmur...@bitdance.com added the comment: Yes, this working as intended. Consider: 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. class baseClass(object): ... def __init__(self, testList=[]): ... self.testList = testList ... def insertItem(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'] See http://docs.python.org/faq/design.html#why-are-default-values-shared-between-objects for an explanation of why. -- nosy: +r.david.murray priority: - normal resolution: - invalid stage: - committed/rejected status: open - closed type: - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7465 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7465] Call to another class's constructor in unittest.TestCase.setUp returns the same instance multiple times
R. David Murray rdmur...@bitdance.com added the comment: Heh, that first b = baseClass(); del b wasn't supposed to be there and doesn't change the result, just in case you were wondering. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7465 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com