[New-bugs-announce] [issue7465] Call to another class's constructor in unittest.TestCase.setUp returns the same instance

Aaron Altman report at bugs.python.org
Thu Dec 10 03:20:56 CET 2009


New submission from Aaron Altman <aaron at tomorrowsfunction.com>:

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.

----------
components: Library (Lib), Tests
files: unittest_doesnt_reinstantiate_members.txt
messages: 96189
nosy: awaltman
severity: normal
status: open
title: Call to another class's constructor in unittest.TestCase.setUp returns the same instance
versions: Python 2.6
Added file: http://bugs.python.org/file15514/unittest_doesnt_reinstantiate_members.txt

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7465>
_______________________________________


More information about the New-bugs-announce mailing list