Best Python code snippet using Kiwi_python
tests.py
Source:tests.py
...8from django.urls import path, reverse9from django.views.decorators.clickjacking import xframe_options_exempt10from . import urls11from .middleware import StackOverflowMiddleware12def exception_view(request):13 User.objects.get(pk=1)14def empty_view(request):15 return HttpResponse()16@xframe_options_exempt17def empty_view_no_xframe(request):18 return HttpResponse()19urls.urlpatterns.extend(20 [21 path('exception', exception_view, name='exception_view'),22 path('empty', empty_view, name='empty_view'),23 path('empty-no-xframe', empty_view_no_xframe, name='empty_view_no_xframe'),24 ]25)26class StackOverflowMiddlewareTests(TestCase):...
jsonrpc.py
Source:jsonrpc.py
1"""2Patching pyrmid_jsonrpc to handle HTTPForbidden exceptions3"""4from pyramid_rpc import jsonrpc5from pyramid.httpexceptions import HTTPForbidden6import functools7class JsonRpcUnauthorized(jsonrpc.JsonRpcError):8 """Extends pyramid_rpc.jsonrpc.JsonRpcError,9 represents a 'client unauthorized' exception."""10 code = -3240311 message = 'client unauthorized'12def add_dd_exceptions(f):13 """pyramid_rpc.jsonrpc.exception_view monkeypatcher"""14 @functools.wraps(f)15 def wrapper(exc, request):16 rpc_id = getattr(request, 'rpc_id', None)17 if isinstance(exc, HTTPForbidden):18 fault = JsonRpcUnauthorized()19 jsonrpc.log.debug('json-rpc method unauthorized rpc_id:%s "%s"',20 rpc_id, request.rpc_method)21 return jsonrpc.make_error_response(request, fault, rpc_id)22 return f(exc, request)23 return wrapper...
exception_view.py
Source:exception_view.py
1# -*- coding: utf-8 -*-2# @Author: ty3# @File name: exception_view.py 4# @IDE: PyCharm5# @Create time: 12/28/20 11:15 PM6from flask import Blueprint, jsonify7from app.models.models import GlobalApiException8exception_view = Blueprint('exception', __name__, url_prefix='', static_folder='../../static',9 template_folder='../../templates')10@exception_view.app_errorhandler(GlobalApiException)11def api_exception(ex):...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!