help: Unit test fixture returning the same object

Peter Hansen peter at engcorp.com
Tue Aug 3 21:29:19 EDT 2004


Michael McCracken wrote:

> The problem is that in each test case, setUp and tearDown are called
> as expected according to the print statements, but they don't seem to
> have any effect after the first invocation. self.testfile is always
> the same instance as reported by id().

What Roy said... but to prove it to yourself, if you need to,
just implement a little class-variable-based counter in the
File __init__ method to show that you are getting different
objects each time.  (That is, increment a global counter
each time you go through __init__, and store the current
count in the instance, to be retrieved and shown when you
are printing the ids() for the objects.)

-Peter



More information about the Python-list mailing list