def METHOD_NAME(self):
    user = UserFactory.create()
    UserPreferenceFactory.create(user=user, key="testkey", value="first")
    with self.allow_transaction_exception():
        pytest.raises(IntegrityError, UserPreferenceFactory.create)