当前位置: 首页>>代码示例>>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;未经允许,请勿转载。