          module is used, if it exists.
  
          Returns the filesystem path to the temporary migrations module.
          """
          temp_dir = tempfile.mkdtemp()
          try:
              target_dir = tempfile.mkdtemp(dir=temp_dir)
              with open(os.path.join(target_dir, '__init__.py'), 'w'):
                  pass
              target_migrations_dir = os.path.join(target_dir, 'migrations')
  
 
</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 
        finally:
            shutil.rmtree(temp_dir)
 </s> add  </s> remove         static_dir = tempfile.mkdtemp()
        self.addCleanup(shutil.rmtree, static_dir)

        duplicate = os.path.join(static_dir, 'test', 'file.txt')
        os.mkdir(os.path.dirname(duplicate))
        with open(duplicate, 'w+') as f:
            f.write('duplicate of file.txt')
 </s> add         with tempfile.TemporaryDirectory() as static_dir:
            duplicate = os.path.join(static_dir, 'test', 'file.txt')
            os.mkdir(os.path.dirname(duplicate))
            with open(duplicate, 'w+') as f:
                f.write('duplicate of file.txt') </s> remove         tmp_dir = tempfile.mkdtemp()
        try:
 </s> add         with tempfile.TemporaryDirectory() as tmp_dir: </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)
        with tempfile.TemporaryDirectory() as temp_dir:
          module is used, if it exists.
  
          Returns the filesystem path to the temporary migrations module.
          """
        with tempfile.TemporaryDirectory() as temp_dir:
        with tempfile.TemporaryDirectory() as temp_dir:
              target_dir = tempfile.mkdtemp(dir=temp_dir)
              with open(os.path.join(target_dir, '__init__.py'), 'w'):
                  pass
              target_migrations_dir = os.path.join(target_dir, 'migrations')
  
keep keep keep keep replace replace keep keep keep keep keep
 Refs #23919 -- Replaced tempfile.mkdtemp() with TemporaryDirectory() context manager. 
tests/migrations/test_base.py