title: Unittest teardown() del all attributes
body: <p>I have unit tests with setup and teardown methods which look like this:</p>
  
  <pre><code>def setUp(self):
     self.foo = "bar"
     self.bar = "foo"
  
  def tearDown(self):
     del self.foo
     del self.bar
  </code></pre>
  
  <p>Is there a cleaner way to call <code>__del__</code> on every object I instantiate in <code>setUp</code>? If I don't do this then connections to a MySQL database which are opened in <code>setUp</code> (by instantiating those objects) seem to remain open after every test.</p>
  
  <p><em>Ideally</em> I would of course figure out the underlying problem (why those database connections aren't being closed when the test finishes and the test case is discarded). In the meantime though, is there a cleaner way to <code>del</code> all those objects?</p>
  
  <p>The database connections are created using the <code>MySQLdb</code> library, there is also a destructor to close the connection:</p>
  
  <pre><code>class Foo(object):
  
      def __init__(self,some_credentials):
          self.db_connection = MySQLdb.connect(some_credentials)
  
      def __del__(self):
          self.db_connection.close()
  </code></pre>