当前位置: 首页>>代码示例>>Python>>正文


Python Rule.parse方法代码示例

本文整理汇总了Python中Rule.Rule.parse方法的典型用法代码示例。如果您正苦于以下问题:Python Rule.parse方法的具体用法?Python Rule.parse怎么用?Python Rule.parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rule.Rule的用法示例。


在下文中一共展示了Rule.parse方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_rule_txt_with_three_rules

# 需要导入模块: from Rule import Rule [as 别名]
# 或者: from Rule.Rule import parse [as 别名]
 def test_rule_txt_with_three_rules(self):
     txt_rule = "L1>=20\n" \
                "L2=3\n" \
                "W<=90".splitlines()
     exp_result = [("L1", ">=", 20),
                   ("L2", "=", 3),
                   ("W", "<=", 90)]
     self.assertEqual(exp_result, Rule.parse(txt_rule))
开发者ID:zverxw13,项目名称:LearnMath,代码行数:10,代码来源:RuleTest.py

示例2: test_W_03

# 需要导入模块: from Rule import Rule [as 别名]
# 或者: from Rule.Rule import parse [as 别名]
    def test_W_03(self):
        txt_rule = "L1>0\n" \
                   "L1<10\n" \
                   "L2>0\n" \
                   "L2<10\n" \
                   "W==90".splitlines()
        rules = Rule.parse(txt_rule)

        Equation.validate_rules_for_w(rules)
开发者ID:zverxw13,项目名称:LearnMath,代码行数:11,代码来源:RuleTest.py

示例3: test_W_01

# 需要导入模块: from Rule import Rule [as 别名]
# 或者: from Rule.Rule import parse [as 别名]
    def test_W_01(self):
        txt_rule = "L1>0\n" \
                   "L1<10\n" \
                   "L2>0\n" \
                   "L2<10\n" \
                   "W<=90".splitlines()
        rules = Rule.parse(txt_rule)

        exceptions = (RuleException)
        with self.assertRaises(exceptions):
            Equation.validate_rules_for_w(rules)
开发者ID:zverxw13,项目名称:LearnMath,代码行数:13,代码来源:RuleTest.py

示例4: test_rule_txt_with_one_rule_and_spaces

# 需要导入模块: from Rule import Rule [as 别名]
# 或者: from Rule.Rule import parse [as 别名]
 def test_rule_txt_with_one_rule_and_spaces(self):
     txt_rule = "L1 >= 20".splitlines()
     exp_result = [("L1", ">=", 20)]
     self.assertEqual(exp_result, Rule.parse(txt_rule))
开发者ID:zverxw13,项目名称:LearnMath,代码行数:6,代码来源:RuleTest.py

示例5: test_rule_txt_with_two_rules

# 需要导入模块: from Rule import Rule [as 别名]
# 或者: from Rule.Rule import parse [as 别名]
 def test_rule_txt_with_two_rules(self):
     txt_rule = "L1>=20\n" \
                "L2=3".splitlines()
     exp_result = [("L1", ">=", 20),
                   ("L2", "=", 3)]
     self.assertEqual(exp_result, Rule.parse(txt_rule))
开发者ID:zverxw13,项目名称:LearnMath,代码行数:8,代码来源:RuleTest.py

示例6: test_rule_txt_as_none

# 需要导入模块: from Rule import Rule [as 别名]
# 或者: from Rule.Rule import parse [as 别名]
 def test_rule_txt_as_none(self):
     exceptions = (RuleException)
     with self.assertRaises(exceptions):
         Rule.parse(None)
开发者ID:zverxw13,项目名称:LearnMath,代码行数:6,代码来源:RuleTest.py

示例7: test_rule_txt_with_missing_value

# 需要导入模块: from Rule import Rule [as 别名]
# 或者: from Rule.Rule import parse [as 别名]
 def test_rule_txt_with_missing_value(self):
     exceptions = (RuleException)
     with self.assertRaises(exceptions):
         txt_rule = "L1>=".splitlines()
         Rule.parse(txt_rule)
开发者ID:zverxw13,项目名称:LearnMath,代码行数:7,代码来源:RuleTest.py

示例8: test_rule_txt_with_invalid_value_02

# 需要导入模块: from Rule import Rule [as 别名]
# 或者: from Rule.Rule import parse [as 别名]
 def test_rule_txt_with_invalid_value_02(self):
     exceptions = (RuleException)
     with self.assertRaises(exceptions):
         txt_rule = "L1>=10.6".splitlines()
         Rule.parse(txt_rule)
开发者ID:zverxw13,项目名称:LearnMath,代码行数:7,代码来源:RuleTest.py

示例9: test_rule_txt_with_invalid_operand_02

# 需要导入模块: from Rule import Rule [as 别名]
# 或者: from Rule.Rule import parse [as 别名]
 def test_rule_txt_with_invalid_operand_02(self):
     exceptions = (RuleException)
     with self.assertRaises(exceptions):
         txt_rule = "L1<>20".splitlines()
         Rule.parse(txt_rule)
开发者ID:zverxw13,项目名称:LearnMath,代码行数:7,代码来源:RuleTest.py

示例10: test_rule_txt_with_missing_element

# 需要导入模块: from Rule import Rule [as 别名]
# 或者: from Rule.Rule import parse [as 别名]
 def test_rule_txt_with_missing_element(self):
     exceptions = (RuleException)
     with self.assertRaises(exceptions):
         txt_rule = " >=20".splitlines()
         Rule.parse(txt_rule)
开发者ID:zverxw13,项目名称:LearnMath,代码行数:7,代码来源:RuleTest.py

示例11: test_rule_txt_with_invalid_element_02

# 需要导入模块: from Rule import Rule [as 别名]
# 或者: from Rule.Rule import parse [as 别名]
 def test_rule_txt_with_invalid_element_02(self):
     exceptions = (RuleException)
     with self.assertRaises(exceptions):
         txt_rule = "12>=20".splitlines()
         Rule.parse(txt_rule)
开发者ID:zverxw13,项目名称:LearnMath,代码行数:7,代码来源:RuleTest.py

示例12: test_rule_txt_as_empty_string

# 需要导入模块: from Rule import Rule [as 别名]
# 或者: from Rule.Rule import parse [as 别名]
 def test_rule_txt_as_empty_string(self):
     exceptions = (RuleException)
     self.assertEqual([], Rule.parse(""))
开发者ID:zverxw13,项目名称:LearnMath,代码行数:5,代码来源:RuleTest.py


注:本文中的Rule.Rule.parse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。