def test_parse_rule_validates_code_examples(kwargs): """ Ensure parse_rule raises an exception if code examples are syntactically invalid. """ with pytest.raises(InvalidNode): parse_rule(rule_name='', rule_values=dict(description='', expr=XPath("//Num"), **kwargs))
def test_parse_rule_requires_settings(): """Ensure parse_rule raises an exception if settings are not provided.""" with pytest.raises(InvalidNode): parse_rule(rule_name='', rule_values=dict( description='', expr=XPath("//Num"), example="a = 1", instead="a = int('1')", ))
def test_parse_rule(): """Ensure parse_rule returns expected output.""" expr = XPath("//Num") assert parse_rule( rule_name='', rule_values=dict( description='', expr=expr, example="a = 1", instead="a = int('1')", settings=Settings(included=[], excluded=[], allow_ignore=True), ) ) == Rule( name='', description='', expr=expr, example="a = 1", instead="a = int('1')", settings=Settings(included=[], excluded=[], allow_ignore=True) )