本文整理汇总了Python中trac.web.chrome.Chrome.match_request方法的典型用法代码示例。如果您正苦于以下问题:Python Chrome.match_request方法的具体用法?Python Chrome.match_request怎么用?Python Chrome.match_request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.web.chrome.Chrome
的用法示例。
在下文中一共展示了Chrome.match_request方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ChromeTestCase2
# 需要导入模块: from trac.web.chrome import Chrome [as 别名]
# 或者: from trac.web.chrome.Chrome import match_request [as 别名]
class ChromeTestCase2(unittest.TestCase):
def setUp(self):
self.env = EnvironmentStub(path=tempfile.mkdtemp())
self.chrome = Chrome(self.env)
def tearDown(self):
shutil.rmtree(self.env.path)
def test_malicious_filename_raises(self):
req = Request(path_info='/chrome/site/../conf/trac.ini')
self.assertTrue(self.chrome.match_request(req))
self.assertRaises(TracError, self.chrome.process_request, req)
def test_empty_shared_htdocs_dir_raises_file_not_found(self):
req = Request(path_info='/chrome/shared/trac_logo.png')
self.assertEqual('', self.chrome.shared_htdocs_dir)
self.assertTrue(self.chrome.match_request(req))
from trac.web.api import HTTPNotFound
self.assertRaises(HTTPNotFound, self.chrome.process_request, req)
def test_shared_htdocs_dir_file_is_found(self):
from trac.web.api import RequestDone
def send_file(path, mimetype):
raise RequestDone
req = Request(path_info='/chrome/shared/trac_logo.png',
send_file=send_file)
shared_htdocs_dir = os.path.join(self.env.path, 'chrome', 'shared')
os.makedirs(shared_htdocs_dir)
create_file(os.path.join(shared_htdocs_dir, 'trac_logo.png'))
self.env.config.set('inherit', 'htdocs_dir', shared_htdocs_dir)
self.assertTrue(self.chrome.match_request(req))
self.assertRaises(RequestDone, self.chrome.process_request, req)