本文整理汇总了Python中debug_toolbar.middleware.DebugToolbarMiddleware._show_toolbar方法的典型用法代码示例。如果您正苦于以下问题:Python DebugToolbarMiddleware._show_toolbar方法的具体用法?Python DebugToolbarMiddleware._show_toolbar怎么用?Python DebugToolbarMiddleware._show_toolbar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类debug_toolbar.middleware.DebugToolbarMiddleware
的用法示例。
在下文中一共展示了DebugToolbarMiddleware._show_toolbar方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_show_toolbar_TEST
# 需要导入模块: from debug_toolbar.middleware import DebugToolbarMiddleware [as 别名]
# 或者: from debug_toolbar.middleware.DebugToolbarMiddleware import _show_toolbar [as 别名]
def test_show_toolbar_TEST(self):
request = rf.get('/')
middleware = DebugToolbarMiddleware()
with Settings(INTERNAL_IPS=['127.0.0.1'], TEST=True, DEBUG=True):
self.assertFalse(middleware._show_toolbar(request))
with Settings(INTERNAL_IPS=['127.0.0.1'], TEST=False, DEBUG=True):
self.assertTrue(middleware._show_toolbar(request))
示例2: test_show_toolbar_TEST
# 需要导入模块: from debug_toolbar.middleware import DebugToolbarMiddleware [as 别名]
# 或者: from debug_toolbar.middleware.DebugToolbarMiddleware import _show_toolbar [as 别名]
def test_show_toolbar_TEST(self):
request = self.request
middleware = DebugToolbarMiddleware()
with Settings(TEST=True, DEBUG=True):
self.assertFalse(middleware._show_toolbar(request))
with Settings(TEST=False, DEBUG=True):
self.assertTrue(middleware._show_toolbar(request))
示例3: test_show_toolbar_INTERNAL_IPS
# 需要导入模块: from debug_toolbar.middleware import DebugToolbarMiddleware [as 别名]
# 或者: from debug_toolbar.middleware.DebugToolbarMiddleware import _show_toolbar [as 别名]
def test_show_toolbar_INTERNAL_IPS(self):
request = rf.get('/')
request.META = {'REMOTE_ADDR': '127.0.0.1'}
middleware = DebugToolbarMiddleware()
with Settings(INTERNAL_IPS=['127.0.0.1'], DEBUG=True):
self.assertTrue(middleware._show_toolbar(request))
with Settings(INTERNAL_IPS=[], DEBUG=True):
self.assertFalse(middleware._show_toolbar(request))
示例4: test_show_toolbar_TEST
# 需要导入模块: from debug_toolbar.middleware import DebugToolbarMiddleware [as 别名]
# 或者: from debug_toolbar.middleware.DebugToolbarMiddleware import _show_toolbar [as 别名]
def test_show_toolbar_TEST(self):
request = self.request
request.META = {'REMOTE_ADDR': '127.0.0.1'}
middleware = DebugToolbarMiddleware()
with Settings(INTERNAL_IPS=['127.0.0.1'], TEST=True, DEBUG=True):
self.assertFalse(middleware._show_toolbar(request))
with Settings(INTERNAL_IPS=['127.0.0.1'], TEST=False, DEBUG=True):
self.assertTrue(middleware._show_toolbar(request))
示例5: test_show_toolbar_INTERNAL_IPS
# 需要导入模块: from debug_toolbar.middleware import DebugToolbarMiddleware [as 别名]
# 或者: from debug_toolbar.middleware.DebugToolbarMiddleware import _show_toolbar [as 别名]
def test_show_toolbar_INTERNAL_IPS(self):
request = self.request
request.META = {"REMOTE_ADDR": "127.0.0.1"}
middleware = DebugToolbarMiddleware()
with Settings(INTERNAL_IPS=["127.0.0.1"], DEBUG=True):
self.assertTrue(middleware._show_toolbar(request))
with Settings(INTERNAL_IPS=[], DEBUG=True):
self.assertFalse(middleware._show_toolbar(request))