title: How to classically remove a TemporaryDirectory (without `with` statement)
body: <p><code>Tempfile</code> is normaly used in combination with the <code>with</code> statement. I would like to use it without it in a unittest class. The tests create a number of files which do not interfer with each other. Thus, I planned to just create a temp dir in which I dump them all and remove the dir when the test class finished. However, I could not find how to remove the TemporaryDirectory in tearDownClass(cls)? Do I have to do anything at all. Is there a better approach?</p>
  
  <pre class="lang-py prettyprint-override"><code>
  import pathlib
  import tempfile
  import unittest
  
  
  class MyTest(unittest.TestCase):
  
      @classmethod
      def setUpClass(cls) -&gt; None:
          cls.temp_dir = tempfile.TemporaryDirectory()
  
      @classmethod
      def tearDownClass(cls) -&gt; None:
          # How can I close the tempfile here?
          # cls.temp_dir.close() &lt;- does not exist
  
      def test_save_file(self):
          file_path = pathlib.Path(temp_dir.name) / "my_file.abc"
          # Function which saves stuff into file
  
      # more tests which store other files into the temp_dir
  
  </code></pre>