R. David Murray added the comment:

GC cleanup is not guaranteed to be synchronous.  You are observing normal 
Python behavior here.  Cleanup does not happen until the TestCase instance is 
finalized (thus eliminating the self.dummy reference to your DummyClass).  In 
the case of passing tests, that is after the '.' is printed.  In the case of 
failing tests, that is after the failure is printed, which isn't until the 
failure summary is printed at after running all tests.

If it is important to you that DummyClass be finalized, you need to add an 
addCleanup call to your setUp method that will do whatever finalization you 
need done.  Including doing 'del self.dummy' (or self.dummy = None) if you need 
the reference to it gone...but depending on garbage collection is a bad idea, 
so if you are doing that there is probably something sub-optimal about your 
design.

----------
nosy: +r.david.murray
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue31261>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to