              with self.storage.open('raced/test.file') as f:
                  self.assertEqual(f.read(), b'saved with race')
  
              # Check that OSErrors aside from EEXIST are still raised.
              self.assertRaises(OSError,
                  self.storage.save, 'error/test.file', ContentFile('not saved'))
          finally:
              os.makedirs = real_makedirs
  
      def test_remove_race_handling(self):
          """
 
</s> remove             self.assertRaises(OSError, self.storage.delete, 'error.file')
 </s> add             with self.assertRaises(OSError):
                self.storage.delete('error.file') </s> remove         self.assertRaises(
            DatabaseError,
            lambda: list(Thing.objects.all()),
        )
 </s> add         with self.assertRaises(DatabaseError):
            list(Thing.objects.all()) </s> remove         self.assertRaises(
            DatabaseError,
            lambda: list(Author.objects.all()),
        )
 </s> add         with self.assertRaises(DatabaseError):
            list(Author.objects.all()) </s> remove         self.assertRaises(IntegrityError, UniqueTest.objects.create, year=2012, slug="foo")
 </s> add         with self.assertRaises(IntegrityError):
            UniqueTest.objects.create(year=2012, slug="foo") </s> remove         self.assertRaises(IntegrityError, TagUniqueRename.objects.create, title="bar", slug2="foo")
 </s> add         with self.assertRaises(IntegrityError):
            TagUniqueRename.objects.create(title="bar", slug2="foo")
            with self.assertRaises(OSError):
                self.storage.save('error/test.file', ContentFile('not saved'))
              with self.storage.open('raced/test.file') as f:
                  self.assertEqual(f.read(), b'saved with race')
  
              # Check that OSErrors aside from EEXIST are still raised.
            with self.assertRaises(OSError):
                self.storage.save('error/test.file', ContentFile('not saved'))
            with self.assertRaises(OSError):
                self.storage.save('error/test.file', ContentFile('not saved'))
          finally:
              os.makedirs = real_makedirs
  
      def test_remove_race_handling(self):
          """
keep keep keep keep replace replace keep keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/file_storage/tests.py