Skip to content

Fix ignoring __init__.robot.md and __init__.robot.rst initialization files (fixes #5853) - #5865

Open
imsurya26 wants to merge 2 commits into
robotframework:masterfrom
imsurya26:fix/5853-init-compound-extension
Open

imsurya26 wants to merge 2 commits into
robotframework:masterfrom
imsurya26:fix/5853-init-compound-extension

Conversation

@imsurya26

Copy link
Copy Markdown

Summary

Fixes #5853.

When discovering test suite structure, SuiteStructureBuilder._is_init_file previously checked path.stem.lower() == '__init__'.

Because Python pathlib.Path.stem only strips the final suffix, Path('__init__.robot.md').stem evaluates to '__init__.robot'. As a result, valid suite initialization files with compound extensions (such as .robot.md and .robot.rst) were not recognized as initialization files. Since their filename starts with _, they were subsequently treated as ignored files and skipped entirely.

Changes

  • In src/robot/parsing/suitestructure.py:
    • Update _is_init_file to verify path.name.lower() == f"__init__.{self.extensions.get_extension(path)}".
  • In utest/parsing/test_suitestructure.py:
    • Added unit tests in TestSuiteStructureBuilder testing __init__.robot, __init__.robot.md, __init__.robot.rst, case insensitivity, and custom extensions.
  • In atest/robot/parsing/init_file_formats.robot and atest/testdata/parsing/init_file_formats/:
    • Added end-to-end acceptance tests verifying that directory suites with __init__.robot.md and __init__.robot.rst load suite documentation and execute suite setup properly.

…files (robotframework#5853)

When discovering suite structure, SuiteStructureBuilder._is_init_file checked path.stem.lower() == '__init__'. For compound extensions like .robot.md and .robot.rst, path.stem retains .robot (e.g. __init__.robot), causing the initialization files to be treated as unrecognized hidden files and ignored.

Compare path.name.lower() with f'__init__.{self.extensions.get_extension(path)}' instead, so compound extensions are properly recognized. Add unit tests and acceptance tests.
Copilot AI balanced review requested due to automatic review settings November 20, 2026 08:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@d-biehl d-biehl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reported #5853 and had planned to send a PR for it myself, so thanks a lot for picking this up! I tested the change locally on top of current master (Python 3.13). __init__.robot.md and __init__.robot.rst are now used as initialization files with the default extensions, with upper-case names, with --extension robot.md, with --parseinclude, when the init file is given directly as a data source, and with a custom parser for a compound extension. __init__.robot, and __init__.md with --extension md, work as before. The unit tests and the acceptance tests under parsing and cli/runner pass, and the new tests fail without the fix.

One behavior change worth knowing: if a directory contains both __init__.robot and __init__.robot.md, the second one now gets the usual "Ignoring second test suite init file" error instead of being silently ignored. I think that is correct.

Check Log Message ${SUITE.setup.messages[0]} Init setup in .robot.md
Should Contain Tests ${SUITE} Example Test

Init file with '.robot.rst' extension

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other reST acceptance tests are tagged require-docutils (see Force Tags in atest/robot/parsing/data_formats/rest.robot), so they can be excluded when docutils is not installed:

Suggested change
Init file with '.robot.rst' extension
Init file with '.robot.rst' extension
[Tags] require-docutils

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for testing it so thoroughly, and for the pointer. Added [Tags] require-docutils to the .robot.rst test in aba2862, matching the other reST acceptance tests.

Copilot AI balanced review requested due to automatic review settings December 1, 2026 01:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suite initialization files __init__.robot.md and __init__.robot.rst are ignored

3 participants