Issue #24675: Avoid DeprecationWarning in test_os

Patch written by Martin Panter. I replace tearDown() with addCleanup().
1 file changed