diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index 77810bdf0a9..74a036f2022 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -70,7 +70,7 @@ jobs: env: # Number of expected test passes, safety measure for accidental skip of # tests. Update value if you add/remove tests. - PYTEST_REQPASS: 829 + PYTEST_REQPASS: 831 steps: - uses: actions/checkout@v4 with: diff --git a/plugins/modules/fake_module.py b/plugins/modules/fake_module.py index bdff5c7e4db..1c4ab424fd1 100644 --- a/plugins/modules/fake_module.py +++ b/plugins/modules/fake_module.py @@ -4,6 +4,14 @@ """ from ansible.module_utils.basic import AnsibleModule +EXAMPLES = r""" +- name: "playbook" + tasks: + - name: Hello + debug: + msg: 'world' +""" + def main() -> None: """Return the module instance.""" diff --git a/test/test_file_utils.py b/test/test_file_utils.py index 81faa3253a0..d94b631bdfa 100644 --- a/test/test_file_utils.py +++ b/test/test_file_utils.py @@ -258,6 +258,11 @@ def test_discover_lintables_umlaut(monkeypatch: MonkeyPatch) -> None: "playbook", id="43", ), # content should determine it as a play + pytest.param( + "plugins/modules/fake_module.py", + "plugin", + id="44", + ), ), ) def test_kinds(path: str, kind: FileType) -> None: @@ -536,3 +541,13 @@ def test_bug_2513( results = Runner(filename, rules=default_rules_collection).run() assert len(results) == 1 assert results[0].rule.id == "name" + + +def test_examples_content() -> None: + """Test that a module loads the correct content.""" + filename = Path("plugins/modules/fake_module.py") + lintable = Lintable(filename) + # Lintable is now correctly purporting to be a YAML file + assert lintable.base_kind == "text/yaml" + # Lintable content should be contents of EXAMPLES + assert lintable.content == "---" + BASIC_PLAYBOOK