當前位置: 首頁>>代碼示例>>Python>>正文


Python Rule.test方法代碼示例

本文整理匯總了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")
開發者ID:stereohead,項目名稱:wsgi-cahin,代碼行數:16,代碼來源:tests.py

示例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")
開發者ID:stereohead,項目名稱:wsgi-cahin,代碼行數:8,代碼來源:tests.py

示例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())
開發者ID:stereohead,項目名稱:wsgi-cahin,代碼行數:7,代碼來源:tests.py

示例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)
開發者ID:stereohead,項目名稱:wsgi-cahin,代碼行數:8,代碼來源:tests.py

示例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"))
開發者ID:stereohead,項目名稱:wsgi-cahin,代碼行數:8,代碼來源:tests.py

示例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)
開發者ID:stereohead,項目名稱:wsgi-cahin,代碼行數:8,代碼來源:tests.py

示例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)
開發者ID:stereohead,項目名稱:wsgi-cahin,代碼行數:8,代碼來源:tests.py

示例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())
開發者ID:stereohead,項目名稱:wsgi-cahin,代碼行數:5,代碼來源:tests.py

示例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())
開發者ID:stereohead,項目名稱:wsgi-cahin,代碼行數:5,代碼來源:tests.py

示例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())
開發者ID:stereohead,項目名稱:wsgi-cahin,代碼行數:7,代碼來源:tests.py

示例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")
開發者ID:stereohead,項目名稱:wsgi-cahin,代碼行數:8,代碼來源:tests.py

示例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")
開發者ID:stereohead,項目名稱:wsgi-cahin,代碼行數:8,代碼來源:tests.py

示例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())
開發者ID:stereohead,項目名稱:wsgi-cahin,代碼行數:7,代碼來源:tests.py


注:本文中的rule.Rule.test方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。