本文整理匯總了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())