本文整理汇总了Python中debug_toolbar.middleware.DebugToolbarMiddleware.process_request方法的典型用法代码示例。如果您正苦于以下问题:Python DebugToolbarMiddleware.process_request方法的具体用法?Python DebugToolbarMiddleware.process_request怎么用?Python DebugToolbarMiddleware.process_request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类debug_toolbar.middleware.DebugToolbarMiddleware
的用法示例。
在下文中一共展示了DebugToolbarMiddleware.process_request方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_tuple_urlconf
# 需要导入模块: from debug_toolbar.middleware import DebugToolbarMiddleware [as 别名]
# 或者: from debug_toolbar.middleware.DebugToolbarMiddleware import process_request [as 别名]
def test_tuple_urlconf(self):
request = rf.get('/')
urls = __import__('tests.urls').urls
urls.urlpatterns = tuple(urls.urlpatterns)
request.urlconf = urls
middleware = DebugToolbarMiddleware()
with Settings(INTERNAL_IPS=['127.0.0.1'], DEBUG=True):
middleware.process_request(request)
self.assertFalse(isinstance(request.urlconf, basestring))
示例2: test_tuple_urlconf
# 需要导入模块: from debug_toolbar.middleware import DebugToolbarMiddleware [as 别名]
# 或者: from debug_toolbar.middleware.DebugToolbarMiddleware import process_request [as 别名]
def test_tuple_urlconf(self):
request = rf.get('/')
urls = __import__('tests.urls').urls
urls.urlpatterns = tuple(urls.urlpatterns)
request.urlconf = urls
middleware = DebugToolbarMiddleware()
middleware.process_request(request)
self.assertFalse(isinstance(request.urlconf, six.string_types))
示例3: test_request_urlconf_string
# 需要导入模块: from debug_toolbar.middleware import DebugToolbarMiddleware [as 别名]
# 或者: from debug_toolbar.middleware.DebugToolbarMiddleware import process_request [as 别名]
def test_request_urlconf_string(self):
request = rf.get('/')
set_urlconf('tests.urls')
middleware = DebugToolbarMiddleware()
middleware.process_request(request)
patterns = get_resolver(get_urlconf()).url_patterns
self.assertTrue(hasattr(patterns[1], '_callback_str'))
self.assertEqual(patterns[-1]._callback_str, 'tests.views.execute_sql')
示例4: test_request_urlconf_string
# 需要导入模块: from debug_toolbar.middleware import DebugToolbarMiddleware [as 别名]
# 或者: from debug_toolbar.middleware.DebugToolbarMiddleware import process_request [as 别名]
def test_request_urlconf_string(self):
request = rf.get('/')
request.urlconf = 'tests.urls'
middleware = DebugToolbarMiddleware()
with Settings(INTERNAL_IPS=['127.0.0.1'], DEBUG=True):
middleware.process_request(request)
self.assertFalse(isinstance(request.urlconf, basestring))
self.assertTrue(hasattr(request.urlconf.urlpatterns[1], '_callback_str'))
self.assertEquals(request.urlconf.urlpatterns[-1]._callback_str, 'tests.views.execute_sql')
示例5: test_request_urlconf_module
# 需要导入模块: from debug_toolbar.middleware import DebugToolbarMiddleware [as 别名]
# 或者: from debug_toolbar.middleware.DebugToolbarMiddleware import process_request [as 别名]
def test_request_urlconf_module(self):
request = rf.get('/')
request.urlconf = __import__('tests.urls').urls
middleware = DebugToolbarMiddleware()
with self.settings(INTERNAL_IPS=['127.0.0.1'], DEBUG=True):
middleware.process_request(request)
self.assertFalse(isinstance(request.urlconf, six.string_types))
self.assertTrue(hasattr(request.urlconf.urlpatterns[1], '_callback_str'))
self.assertEqual(request.urlconf.urlpatterns[-1]._callback_str, 'tests.views.execute_sql')
示例6: test_request_urlconf_module
# 需要导入模块: from debug_toolbar.middleware import DebugToolbarMiddleware [as 别名]
# 或者: from debug_toolbar.middleware.DebugToolbarMiddleware import process_request [as 别名]
def test_request_urlconf_module(self):
request = rf.get('/')
request.urlconf = __import__('tests.urls').urls
middleware = DebugToolbarMiddleware()
middleware.process_request(request)
self.assertFalse(isinstance(request.urlconf, six.string_types))
patterns = request.urlconf.urlpatterns
self.assertTrue(hasattr(patterns[1], '_callback_str'))
self.assertEqual(patterns[-1]._callback_str, 'tests.views.execute_sql')
示例7: test_request_urlconf_string
# 需要导入模块: from debug_toolbar.middleware import DebugToolbarMiddleware [as 别名]
# 或者: from debug_toolbar.middleware.DebugToolbarMiddleware import process_request [as 别名]
def test_request_urlconf_string(self):
request = self.request
request.urlconf = 'debug_toolbar.tests.urls'
request.META = {'REMOTE_ADDR': '127.0.0.1'}
middleware = DebugToolbarMiddleware()
with Settings(DEBUG=True):
middleware.process_request(request)
self.assertFalse(isinstance(request.urlconf, basestring))
self.assertTrue(hasattr(request.urlconf.urlpatterns[0], '_callback_str'))
self.assertEquals(request.urlconf.urlpatterns[0]._callback_str, 'debug_toolbar.views.debug_media')
self.assertEquals(request.urlconf.urlpatterns[-1].urlconf_name.__name__, 'debug_toolbar.tests.urls')
示例8: test_request_urlconf_string
# 需要导入模块: from debug_toolbar.middleware import DebugToolbarMiddleware [as 别名]
# 或者: from debug_toolbar.middleware.DebugToolbarMiddleware import process_request [as 别名]
def test_request_urlconf_string(self):
request = self.request
request.urlconf = "tests.urls"
request.META = {"REMOTE_ADDR": "127.0.0.1"}
middleware = DebugToolbarMiddleware()
with Settings(INTERNAL_IPS=["127.0.0.1"], DEBUG=True):
middleware.process_request(request)
self.assertFalse(isinstance(request.urlconf, basestring))
self.assertTrue(hasattr(request.urlconf.urlpatterns[0], "_callback_str"))
self.assertEquals(request.urlconf.urlpatterns[0]._callback_str, "debug_toolbar.views.debug_media")
self.assertEquals(request.urlconf.urlpatterns[-1].urlconf_name.__name__, "tests.urls")
示例9: test_request_urlconf_module
# 需要导入模块: from debug_toolbar.middleware import DebugToolbarMiddleware [as 别名]
# 或者: from debug_toolbar.middleware.DebugToolbarMiddleware import process_request [as 别名]
def test_request_urlconf_module(self):
request = self.request
request.urlconf = __import__('tests.urls').urls
request.META = {'REMOTE_ADDR': '127.0.0.1'}
middleware = DebugToolbarMiddleware()
with Settings(INTERNAL_IPS=['127.0.0.1'], DEBUG=True):
middleware.process_request(request)
self.assertFalse(isinstance(request.urlconf, basestring))
self.assertTrue(hasattr(request.urlconf.urlpatterns[0], '_callback_str'))
self.assertEquals(request.urlconf.urlpatterns[0]._callback_str, 'debug_toolbar.views.debug_media')
self.assertTrue(hasattr(request.urlconf.urlpatterns[1], '_callback_str'))
self.assertEquals(request.urlconf.urlpatterns[-1]._callback_str, 'tests.views.execute_sql')