本文整理汇总了Python中webob.Request.subpath方法的典型用法代码示例。如果您正苦于以下问题:Python Request.subpath方法的具体用法?Python Request.subpath怎么用?Python Request.subpath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webob.Request
的用法示例。
在下文中一共展示了Request.subpath方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_redirect_to_subdir
# 需要导入模块: from webob import Request [as 别名]
# 或者: from webob.Request import subpath [as 别名]
def test_redirect_to_subdir(self):
from webob import Request
context = DummyContext()
from StringIO import StringIO
request = Request({'PATH_INFO':'',
'SCRIPT_NAME':'',
'SERVER_NAME':'localhost',
'SERVER_PORT':'80',
'REQUEST_METHOD':'GET',
'wsgi.version':(1,0),
'wsgi.url_scheme':'http',
'wsgi.input':StringIO()})
request.subpath = ('static',)
result = staticapp(context, request)
self.assertEqual(result.status, '301 Moved Permanently')
self.assertEqual(result.location, 'http://localhost/static/')
示例2: test_it
# 需要导入模块: from webob import Request [as 别名]
# 或者: from webob.Request import subpath [as 别名]
def test_it(self):
from webob import Request
context = DummyContext()
from StringIO import StringIO
request = Request({'PATH_INFO':'',
'SCRIPT_NAME':'',
'SERVER_NAME':'localhost',
'SERVER_PORT':'80',
'REQUEST_METHOD':'GET',
'wsgi.version':(1,0),
'wsgi.url_scheme':'http',
'wsgi.input':StringIO()})
request.subpath = ['minimal.pt']
result = staticapp(context, request)
self.assertEqual(result.status, '200 OK')
self.assertEqual(
result.body,
open(os.path.join(here, 'fixtures/minimal.pt'), 'r').read())
示例3: test_file_in_subdir
# 需要导入模块: from webob import Request [as 别名]
# 或者: from webob.Request import subpath [as 别名]
def test_file_in_subdir(self):
from webob import Request
context = DummyContext()
from StringIO import StringIO
request = Request({'PATH_INFO':'',
'SCRIPT_NAME':'',
'SERVER_NAME':'localhost',
'SERVER_PORT':'80',
'REQUEST_METHOD':'GET',
'wsgi.version':(1,0),
'wsgi.url_scheme':'http',
'wsgi.input':StringIO()})
request.subpath = ('static', 'index.html',)
result = staticapp(context, request)
self.assertEqual(result.status, '200 OK')
self.assertEqual(
result.body.replace('\r', ''),
open(os.path.join(here, 'fixtures/static/index.html'), 'r').read())
示例4: test_it
# 需要导入模块: from webob import Request [as 别名]
# 或者: from webob.Request import subpath [as 别名]
def test_it(self):
from webob import Request
context = DummyContext()
from StringIO import StringIO
request = Request(
{
"PATH_INFO": "",
"SCRIPT_NAME": "",
"SERVER_NAME": "localhost",
"SERVER_PORT": "80",
"REQUEST_METHOD": "GET",
"wsgi.version": (1, 0),
"wsgi.url_scheme": "http",
"wsgi.input": StringIO(),
}
)
request.subpath = ["minimal.pt"]
result = staticapp(context, request)
self.assertEqual(result.status, "200 OK")
self.assertEqual(result.body, open(os.path.join(here, "fixtures/minimal.pt"), "r").read())
示例5: test_redirect_to_subdir_with_existing_script_name
# 需要导入模块: from webob import Request [as 别名]
# 或者: from webob.Request import subpath [as 别名]
def test_redirect_to_subdir_with_existing_script_name(self):
from webob import Request
context = DummyContext()
from StringIO import StringIO
request = Request(
{
"PATH_INFO": "/static",
"SCRIPT_NAME": "/script_name",
"SERVER_NAME": "localhost",
"SERVER_PORT": "80",
"REQUEST_METHOD": "GET",
"wsgi.version": (1, 0),
"wsgi.url_scheme": "http",
"wsgi.input": StringIO(),
}
)
request.subpath = ("static",)
result = staticapp(context, request)
self.assertEqual(result.status, "301 Moved Permanently")
self.assertEqual(result.location, "http://localhost/script_name/static/")
示例6: test_file_in_subdir
# 需要导入模块: from webob import Request [as 别名]
# 或者: from webob.Request import subpath [as 别名]
def test_file_in_subdir(self):
from webob import Request
context = DummyContext()
from StringIO import StringIO
request = Request(
{
"PATH_INFO": "",
"SCRIPT_NAME": "",
"SERVER_NAME": "localhost",
"SERVER_PORT": "80",
"REQUEST_METHOD": "GET",
"wsgi.version": (1, 0),
"wsgi.url_scheme": "http",
"wsgi.input": StringIO(),
}
)
request.subpath = ("static", "index.html")
result = staticapp(context, request)
self.assertEqual(result.status, "200 OK")
self.assertEqual(
result.body.replace("\r", ""), open(os.path.join(here, "fixtures/static/index.html"), "r").read()
)