本文整理汇总了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))
示例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)
示例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)
示例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))
示例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))
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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(""))