当前位置: 首页>>代码示例>>Python>>正文


Python DummyRequest.path_url方法代码示例

本文整理汇总了Python中pyramid.testing.DummyRequest.path_url方法的典型用法代码示例。如果您正苦于以下问题:Python DummyRequest.path_url方法的具体用法?Python DummyRequest.path_url怎么用?Python DummyRequest.path_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyramid.testing.DummyRequest的用法示例。


在下文中一共展示了DummyRequest.path_url方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_pass_request_only

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import path_url [as 别名]
 def test_pass_request_only(self):
     """ addslash passes on just the request if that's all that's needed """
     @addslash
     def myview(request):
         return request
     context = object()
     request = DummyRequest()
     request.path_url = '/'
     ret = myview(context, request)
     self.assertEqual(ret, request)
开发者ID:stevearc,项目名称:pyramid_duh,代码行数:12,代码来源:test_view.py

示例2: test_pass_context

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import path_url [as 别名]
 def test_pass_context(self):
     """ addslash passes on the context variable if needed """
     @addslash
     def myview(context, request):
         return context, request
     context = object()
     request = DummyRequest()
     request.path_url = '/'
     ret = myview(context, request)
     self.assertEqual(ret, (context, request))
开发者ID:stevearc,项目名称:pyramid_duh,代码行数:12,代码来源:test_view.py

示例3: test_addslash_redirect

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import path_url [as 别名]
 def test_addslash_redirect(self):
     """ addslash causes redirect if path_url doesn't end in / """
     @addslash
     def myview(request):  # pragma: no cover
         return 'foobar'
     context = object()
     request = DummyRequest()
     request.path_url = '/noslash'
     ret = myview(context, request)
     self.assertTrue(isinstance(ret, HTTPFound))
     self.assertEqual(ret.location, request.path_url + '/')
开发者ID:stevearc,项目名称:pyramid_duh,代码行数:13,代码来源:test_view.py

示例4: test_addslash_redirect_query

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import path_url [as 别名]
 def test_addslash_redirect_query(self):
     """ addslash keeps the query string """
     @addslash
     def myview(request):  # pragma: no cover
         return 'foobar'
     context = object()
     request = DummyRequest()
     request.query_string = 'foo=1&bar=2'
     request.path_url = '/noslash'
     ret = myview(context, request)
     self.assertTrue(isinstance(ret, HTTPFound))
     self.assertEqual(ret.location, request.path_url + '/?' +
                      request.query_string)
开发者ID:stevearc,项目名称:pyramid_duh,代码行数:15,代码来源:test_view.py


注:本文中的pyramid.testing.DummyRequest.path_url方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。