pulp/pulp — pull request #1171 by beav (2014-09-23 16:02:04+00:00)
Title: 1142304 - remove extraneous errors during unit test runs

A few areas of the Pulp code used `__del__` to ensure some cleanup tasks were
completed. However, `__del__` can be called during garbage collection [while
cPython is doing cleanup][del], which results in error messages being
printed to stderr. These messages are ultimately harmless since they occur
during instance teardown. However, we can remove these calls to `__del__` and
rely on other mechanisms instead.

In the *UnitWriter* class, the `__exit__` method will always invoked since the
class is only called by a `with` statement. This is performing the same cleanup
function as the `__del__` method.

In the *Certificate* class, we can do temp dir cleanup directly inside the
`finally` block.

This patch removes the `__del__` methods in these classes and relies on the
aforementioned methods along with regular garbage collection to do cleanup.
When I ran GC stats after making these changes, I didn't see any unaccounted
references.

[del]: https://docs.python.org/2/reference/datamodel.html#object.__del__