本文整理汇总了Python中rule.Rule.test方法的典型用法代码示例。如果您正苦于以下问题:Python Rule.test方法的具体用法?Python Rule.test怎么用?Python Rule.test使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rule.Rule
的用法示例。
在下文中一共展示了Rule.test方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test19
# 需要导入模块: from rule import Rule [as 别名]
# 或者: from rule.Rule import test [as 别名]
def test19(self):
r = Rule("/before/<int:x>/<alphanum:y>/<path:path>")
s = r.test("/before/123/xyz123/some/file.jpg")
self.assertTrue(s.match())
self.assertEqual(s.param("x"), 123)
self.assertEqual(s.param("y"), "xyz123")
self.assertEqual(s.param("path"), "some/file.jpg")
s = r.test("/before/456/qrs789/another/file.jpg")
self.assertTrue(s.match())
self.assertEqual(s.param("x"), 456)
self.assertEqual(s.param("y"), "qrs789")
self.assertEqual(s.param("path"), "another/file.jpg")
示例2: test14
# 需要导入模块: from rule import Rule [as 别名]
# 或者: from rule.Rule import test [as 别名]
def test14(self):
r = Rule("/pages/<alphanum:x>/")
s = r.test("/pages/first/")
self.assertTrue(s.match())
self.assertEqual(s.param("x"), "first")
示例3: test13
# 需要导入模块: from rule import Rule [as 别名]
# 或者: from rule.Rule import test [as 别名]
def test13(self):
r = Rule("<alphanum:x>")
s = r.test("test123")
self.assertTrue(s.match())
示例4: test12
# 需要导入模块: from rule import Rule [as 别名]
# 或者: from rule.Rule import test [as 别名]
def test12(self):
r = Rule("/pages/<int:page_id>/")
s = r.test("/pages/10/")
self.assertTrue(s.match())
self.assertEqual(s.param("page_id"), 10)
示例5: test11
# 需要导入模块: from rule import Rule [as 别名]
# 或者: from rule.Rule import test [as 别名]
def test11(self):
r = Rule("before<int:x>after")
s = r.test("beforeafter")
self.assertFalse(s.match())
self.assertIsNone(s.param("x"))
示例6: test10
# 需要导入模块: from rule import Rule [as 别名]
# 或者: from rule.Rule import test [as 别名]
def test10(self):
r = Rule("<int:x>")
s = r.test("123")
self.assertTrue(s.match())
self.assertEqual(s.param("x"), 123)
示例7: test9
# 需要导入模块: from rule import Rule [as 别名]
# 或者: from rule.Rule import test [as 别名]
def test9(self):
r = Rule("before<int:x>after")
s = r.test("before123after")
self.assertTrue(s.match())
self.assertEqual(s.param("x"), 123)
示例8: test8
# 需要导入模块: from rule import Rule [as 别名]
# 或者: from rule.Rule import test [as 别名]
def test8(self):
r = Rule("test")
self.assertTrue(r.test("test").match())
示例9: test7
# 需要导入模块: from rule import Rule [as 别名]
# 或者: from rule.Rule import test [as 别名]
def test7(self):
r = Rule("test")
self.assertFalse(r.test("blaat").match())
示例10: test20
# 需要导入模块: from rule import Rule [as 别名]
# 或者: from rule.Rule import test [as 别名]
def test20(self):
r = Rule("/home/")
s = r.test("/")
self.assertFalse(s.match())
示例11: test18
# 需要导入模块: from rule import Rule [as 别名]
# 或者: from rule.Rule import test [as 别名]
def test18(self):
r = Rule("/files/<path:path>/")
s = r.test("/files/path/to/some/file (1).jpg")
self.assertFalse(s.match())
self.assertEqual(s.param("path"), "path/to/some/file (1).jpg")
示例12: test16
# 需要导入模块: from rule import Rule [as 别名]
# 或者: from rule.Rule import test [as 别名]
def test16(self):
r = Rule("/files/<path:path>")
s = r.test("/files/first")
self.assertTrue(s.match())
self.assertEqual(s.param("path"), "first")
示例13: test15
# 需要导入模块: from rule import Rule [as 别名]
# 或者: from rule.Rule import test [as 别名]
def test15(self):
r = Rule("/pages/<alphanum:x>/")
s = r.test("/pages/first")
self.assertFalse(s.match())