本文整理汇总了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)
示例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))
示例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 + '/')
示例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)