1. from unittest import mock, skipUnless
    
  2. 
    
  3. from django.db import OperationalError, connection
    
  4. from django.test import TestCase
    
  5. 
    
  6. 
    
  7. @skipUnless(connection.vendor == "sqlite", "SQLite tests.")
    
  8. class FeaturesTests(TestCase):
    
  9.     def test_supports_json_field_operational_error(self):
    
  10.         if hasattr(connection.features, "supports_json_field"):
    
  11.             del connection.features.supports_json_field
    
  12.         msg = "unable to open database file"
    
  13.         with mock.patch.object(
    
  14.             connection,
    
  15.             "cursor",
    
  16.             side_effect=OperationalError(msg),
    
  17.         ):
    
  18.             with self.assertRaisesMessage(OperationalError, msg):
    
  19.                 connection.features.supports_json_field