@mock.patch('django.contrib.contenttypes.models.ContentTypeManager.get_or_create')
    @mock.patch('django.contrib.contenttypes.models.ContentTypeManager.get')
    def test_message_if_get_for_model_fails(self, mocked_get, mocked_get_or_create):

        def _test_message(mocked_method):
            for ExceptionClass in (IntegrityError, OperationalError, ProgrammingError):
                mocked_method.side_effect = ExceptionClass
                with self.assertRaisesMessage(
                    RuntimeError,
                    "Error creating new content types. Please make sure contenttypes "
                    "is migrated before trying to migrate apps individually."
                ):
                    ContentType.objects.get_for_model(ContentType)

        _test_message(mocked_get)

        mocked_get.side_effect = ContentType.DoesNotExist
        _test_message(mocked_get_or_create)
Check that `RuntimeError` with nice error message is raised if
dataset/ETHPy150Open django/django/tests/contenttypes_tests/test_models.py/ContentTypesTests.test_message_if_get_for_model_fails