              self.assertIsInstance(
                  mail.get_connection('django.core.mail.backends.filebased.EmailBackend', file_path=tmp_dir),
                  filebased.EmailBackend
              )
          finally:
              shutil.rmtree(tmp_dir)
          self.assertIsInstance(mail.get_connection(), locmem.EmailBackend)
  
      @override_settings(
          EMAIL_BACKEND='django.core.mail.backends.locmem.EmailBackend',
          ADMINS=[('nobody', 'nobody@example.com')],
 
</s> remove         tmp_dir = tempfile.mkdtemp()
        try:
 </s> add         with tempfile.TemporaryDirectory() as tmp_dir: </s> remove 
        finally:
            shutil.rmtree(temp_dir)
 </s> add  </s> remove     tmpdir = tempfile.mkdtemp()
    original_path = os.path.join(tmpdir, 'original')
    symlink_path = os.path.join(tmpdir, 'symlink')
    os.makedirs(original_path)
    try:
        os.symlink(original_path, symlink_path)
        supported = True
    except (OSError, NotImplementedError, AttributeError):
        supported = False
    else:
        os.remove(symlink_path)
    finally:
        os.rmdir(original_path)
        os.rmdir(tmpdir)
 </s> add     with tempfile.TemporaryDirectory() as temp_dir:
        original_path = os.path.join(temp_dir, 'original')
        symlink_path = os.path.join(temp_dir, 'symlink')
        os.makedirs(original_path)
        try:
            os.symlink(original_path, symlink_path)
            supported = True
        except (OSError, NotImplementedError):
            supported = False </s> remove         # Make sure the warning went away again.
        with self.settings(STATICFILES_DIRS=[static_dir]):
            output = self._collectstatic_output(clear=True)
        self.assertNotIn(self.warning_string, output)
 </s> add             # Make sure the warning went away again.
            with self.settings(STATICFILES_DIRS=[static_dir]):
                output = self._collectstatic_output(clear=True)
            self.assertNotIn(self.warning_string, output) </s> remove         os.remove(duplicate)
 </s> add             os.remove(duplicate)
              self.assertIsInstance(
                  mail.get_connection('django.core.mail.backends.filebased.EmailBackend', file_path=tmp_dir),
                  filebased.EmailBackend
              )


          self.assertIsInstance(mail.get_connection(), locmem.EmailBackend)
  
      @override_settings(
          EMAIL_BACKEND='django.core.mail.backends.locmem.EmailBackend',
          ADMINS=[('nobody', 'nobody@example.com')],
keep keep keep keep replace replace keep keep keep keep keep
 Refs #23919 -- Replaced tempfile.mkdtemp() with TemporaryDirectory() context manager. 
tests/mail/tests.py