help: Unit test fixture returning the same object
Roy Smith
roy at panix.com
Tue Aug 3 21:03:45 EDT 2004
In article <9895e897.0408031533.26720ba0 at posting.google.com>,
michael_mccracken at mac.com (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().
Are you really sure they're the same object? id() just returns the
address of the object in memory. It's possible for two objects to have
the same id as long as their lifetimes never overlap. If you repeatedly
create and destroy the same type of objects in the same context (as
happens in a unittest environment), it's reasonably likely that objects
will reuse the same memory locations.
Other than the oddity of id() returning the same value in different
tests, is something unexpected happening?
More information about the Python-list
mailing list