[Python-Dev] Test cases not garbage collected after run

Fabio Zadrozny fabiofz at gmail.com
Thu Apr 7 18:18:52 CEST 2011


I actually created a bug entry for this
(http://bugs.python.org/issue11798) and just later it occurred that I
should've asked in the list first :)

So, here's the text for opinions:

Right now, when doing a test case, one must clear all the variables
created in the test class, and I believe this shouldn't be needed...

E.g.:

class Test(TestCase):
  def setUp(self):
    self.obj1 = MyObject()

  ...

  def tearDown(self):
    del self.obj1

Ideally (in my view), right after running the test, it should be
garbage-collected and the explicit tearDown just for deleting the
object wouldn't be needed (as the test would be garbage-collected,
that reference would automatically die), because this is currently
very error prone... (and probably a source of leaks for any
sufficiently big test suite).

If that's accepted, I can provide a patch.

Thanks,

Fabio


More information about the Python-Dev mailing list