          with self.settings(STATICFILES_DIRS=[static_dir]):
              output = self._collectstatic_output(clear=True)
          self.assertIn(self.warning_string, output)
  
          os.remove(duplicate)
  
          # 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         # 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         with self.settings(STATICFILES_DIRS=[static_dir]):
            output = self._collectstatic_output(clear=True)
        self.assertIn(self.warning_string, output)
 </s> add             with self.settings(STATICFILES_DIRS=[static_dir]):
                output = self._collectstatic_output(clear=True)
            self.assertIn(self.warning_string, output) </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         static_dir = tempfile.mkdtemp(prefix='collectstatic_empty_staticdir_test')
        with override_settings(STATIC_ROOT=static_dir):
            call_command('collectstatic', interactive=True, stdout=stdout)
        shutil.rmtree(static_dir)
 </s> add         with tempfile.TemporaryDirectory(prefix='collectstatic_empty_staticdir_test') as static_dir:
            with override_settings(STATIC_ROOT=static_dir):
                call_command('collectstatic', interactive=True, stdout=stdout) </s> remove         temp_dir = tempfile.mkdtemp()
        try:
 </s> add         with tempfile.TemporaryDirectory() as temp_dir:
            os.remove(duplicate)
          with self.settings(STATICFILES_DIRS=[static_dir]):
              output = self._collectstatic_output(clear=True)
          self.assertIn(self.warning_string, output)
  
            os.remove(duplicate)
  
          # 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)
keep keep keep keep replace keep keep keep keep keep
 Refs #23919 -- Replaced tempfile.mkdtemp() with TemporaryDirectory() context manager. 
tests/staticfiles_tests/test_management.py