| 1 | """Generic tests for AnsibleLintRule class.""" |
| 2 | |
| 3 | from __future__scip-python python python-stdlib 3.11 __future__/__init__: import annotationsscip-python python python-stdlib 3.11 __future__/annotations.annotations. |
| 4 | |
| 5 | from typingscip-python python python-stdlib 3.11 typing/__init__: import Anyscip-python python python-stdlib 3.11 typing/Any. |
| 6 | |
| 7 | import pytestscip-python python pytest 9.0.3 pytest/__init__: |
| 8 | |
| 9 | from ansiblelint.rulesscip-python python ansible-lint 26 `ansiblelint.rules`/__init__: import AnsibleLintRule, RulesCollection |
| 10 | from ansiblelint.rules.complexityscip-python python ansible-lint 26 `ansiblelint.rules.complexity`/__init__: import ComplexityRule |
| 11 | |
| 12 | |
| 13 | def test_unjinjascip-python python ansible-lint 26 `test.test_ansiblelintrule`/test_unjinja().() -> None: |
| 14 | """Verify that unjinja understands nested mustache.""" |
| 15 | text = "{{ a }} {% b %} {# try to confuse parsing inside a comment { {{}} } #}" |
| 16 | output = "JINJA_EXPRESSION JINJA_STATEMENT JINJA_COMMENT" |
| 17 | assert AnsibleLintRule.unjinja(text) == output |
| 18 | |
| 19 | |
| 20 | @pytestscip-python python pytest 9.0.3 pytest/__init__:.mark.parametrize( |
| 21 | ("rule_name", "rule_config"), |
| 22 | ( |
| 23 | pytestscip-python python pytest 9.0.3 pytest/__init__:.param("load-failure", {}, id="load-failure"), |
| 24 | pytestscip-python python pytest 9.0.3 pytest/__init__:.param("complexity", {}, id="complexity"), |
| 25 | ), |
| 26 | ) |
| 27 | def test_rule_configscip-python python ansible-lint 26 `test.test_ansiblelintrule`/test_rule_config().( |
| 28 | rule_namescip-python python ansible-lint 26 `test.test_ansiblelintrule`/test_rule_config().(rule_name): strscip-python python python-stdlib 3.11 builtins/str#, |
| 29 | rule_configscip-python python ansible-lint 26 `test.test_ansiblelintrule`/test_rule_config().(rule_config): dictscip-python python python-stdlib 3.11 builtins/dict#[strscip-python python python-stdlib 3.11 builtins/str#, Anyscip-python python python-stdlib 3.11 typing/Any.], |
| 30 | empty_rule_collectionscip-python python ansible-lint 26 `test.test_ansiblelintrule`/test_rule_config().(empty_rule_collection): RulesCollection, |
| 31 | ) -> None: |
| 32 | """Check that a rule config can be accessed.""" |
| 33 | empty_rule_collectionscip-python python ansible-lint 26 `test.test_ansiblelintrule`/test_rule_config().(empty_rule_collection).register(ComplexityRule()) |
| 34 | |
| 35 | for rule in empty_rule_collectionscip-python python ansible-lint 26 `test.test_ansiblelintrule`/test_rule_config().(empty_rule_collection): |
| 36 | if rule.id == rule_namescip-python python ansible-lint 26 `test.test_ansiblelintrule`/test_rule_config().(rule_name): |
| 37 | assert rule._collection # noqa: SLF001 |
| 38 | assert rule.rule_config == rule_configscip-python python ansible-lint 26 `test.test_ansiblelintrule`/test_rule_config().(rule_config) |