本文整理匯總了Python中reverser.RSRReverser.reverse方法的典型用法代碼示例。如果您正苦於以下問題:Python RSRReverser.reverse方法的具體用法?Python RSRReverser.reverse怎麽用?Python RSRReverser.reverse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類reverser.RSRReverser
的用法示例。
在下文中一共展示了RSRReverser.reverse方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_rsrreverser_reverse_some_params
# 需要導入模塊: from reverser import RSRReverser [as 別名]
# 或者: from reverser.RSRReverser import reverse [as 別名]
def test_rsrreverser_reverse_some_params():
reverser = RSRReverser('/test/{param1}/{param2}/{param3}')
params = {
'param1': 'epic',
'param2': 'fail',
}
reverser.reverse(params)
示例2: test_rsrreverser_reverse_some_params_and_options
# 需要導入模塊: from reverser import RSRReverser [as 別名]
# 或者: from reverser.RSRReverser import reverse [as 別名]
def test_rsrreverser_reverse_some_params_and_options():
reverser = RSRReverser('/test[/{param1}]/{param2}[/{param3}]/{param4}')
params = {
'param2': 'some',
'param3': 'options',
}
reverser.reverse(params)
示例3: test_rsrreverser_reverse_some_options
# 需要導入模塊: from reverser import RSRReverser [as 別名]
# 或者: from reverser.RSRReverser import reverse [as 別名]
def test_rsrreverser_reverse_some_options():
reverser = RSRReverser('/test[/{param1}][/{param2}][/{param3}]')
params = {
'param2': 'some',
'param3': 'options',
}
reversed_url = '/test/some/options'
assert reverser.reverse(params) == reversed_url
示例4: test_rsrreverer_reverse_plain
# 需要導入模塊: from reverser import RSRReverser [as 別名]
# 或者: from reverser.RSRReverser import reverse [as 別名]
def test_rsrreverer_reverse_plain():
route = '/test/plain/route'
reverser = RSRReverser(route)
params = {
'param1': 'test',
'param2': 'no_sub',
}
assert reverser.reverse(params) == route
示例5: test_rsrreverser_reverse_nested_option_no_parent
# 需要導入模塊: from reverser import RSRReverser [as 別名]
# 或者: from reverser.RSRReverser import reverse [as 別名]
def test_rsrreverser_reverse_nested_option_no_parent():
route = '/test[/{param1}[/{param2}]]/sep[/{param3}[/{param4}]]'
reverser = RSRReverser(route)
params = {
'param2': 'some',
'param4': 'nested_options',
}
reversed_url = '/test/sep'
assert reverser.reverse(params) == reversed_url
示例6: test_rsrreverser_reverse_full_params
# 需要導入模塊: from reverser import RSRReverser [as 別名]
# 或者: from reverser.RSRReverser import reverse [as 別名]
def test_rsrreverser_reverse_full_params():
reverser = RSRReverser('/test/{param1}/{param2}/{param3}')
params = {
'param1': 'params',
'param2': 'are',
'param3': 'fun',
}
reversed_url = '/test/params/are/fun'
assert reverser.reverse(params) == reversed_url
示例7: test_rsrreverser_reverse_full_nested_options
# 需要導入模塊: from reverser import RSRReverser [as 別名]
# 或者: from reverser.RSRReverser import reverse [as 別名]
def test_rsrreverser_reverse_full_nested_options():
reverser = RSRReverser('/test[/{param1}[/{param2}[/{param3}]]]')
params = {
'param1': 'nested',
'param2': 'options',
'param3': 'are_fun',
}
reversed_url = '/test/nested/options/are_fun'
assert reverser.reverse(params) == reversed_url
示例8: test_rsrreverser_reverse_full_params_and_options
# 需要導入模塊: from reverser import RSRReverser [as 別名]
# 或者: from reverser.RSRReverser import reverse [as 別名]
def test_rsrreverser_reverse_full_params_and_options():
reverser = RSRReverser('/test[/{param1}]/{param2}[/{param3}]')
params = {
'param1': 'options',
'param2': 'and',
'param3': 'params_are_fun',
}
reversed_url = '/test/options/and/params_are_fun'
assert reverser.reverse(params) == reversed_url
示例9: test_rsrreverser_reverse_full_options
# 需要導入模塊: from reverser import RSRReverser [as 別名]
# 或者: from reverser.RSRReverser import reverse [as 別名]
def test_rsrreverser_reverse_full_options():
reverser = RSRReverser('/test[/{param1}][/{param2}][/{param3}]')
params = {
'param1': 'options',
'param2': 'are',
'param3': 'fun',
}
reversed_url = '/test/options/are/fun'
assert reverser.reverse(params) == reversed_url
示例10: test_rsrreverser_reverse_invalid_option
# 需要導入模塊: from reverser import RSRReverser [as 別名]
# 或者: from reverser.RSRReverser import reverse [as 別名]
def test_rsrreverser_reverse_invalid_option():
reverser = RSRReverser('/test[/{_p1}][/{p2;}][/{p^3}]')
params = {
'_p1': 'invalid',
'p2;': 'but',
'p^3': 'subs'
}
reversed_url = '/test/invalid/but/subs'
assert reverser.reverse(params) == reversed_url
示例11: test_rsrreverser_reverse_unsafe
# 需要導入模塊: from reverser import RSRReverser [as 別名]
# 或者: from reverser.RSRReverser import reverse [as 別名]
def test_rsrreverser_reverse_unsafe():
reverser = RSRReverser('/test/{param1}/{param2}/{param3}')
params = {
'param1': '#$%^',
'param2': 'unsafe_',
'param3': ';unsafe'
}
reversed_url = '/test/#$%^/unsafe_/;unsafe'
assert reverser.reverse(params) == reversed_url
示例12: test_rsrreverser_reverse_nested_incomplete
# 需要導入模塊: from reverser import RSRReverser [as 別名]
# 或者: from reverser.RSRReverser import reverse [as 別名]
def test_rsrreverser_reverse_nested_incomplete():
route = '/test[/{param1}[/{param2}]]/sep[/{param3}[/{param4}]]'
reverser = RSRReverser(route)
params = {
'param1': 'some',
'param3': 'nested_options',
}
reversed_url = '/test/some/sep/nested_options'
assert reverser.reverse(params) == reversed_url