Skip to content

Fix testcase order - #522

Merged
gkreitz merged 2 commits into
Kattis:masterfrom
gkreitz:fix_testcase_order
Nov 5, 2026
Merged

gkreitz merged 2 commits into
Kattis:masterfrom
gkreitz:fix_testcase_order

Conversation

@gkreitz

@gkreitz gkreitz commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Fixes a bug with the order of test cases. The test case foo was being run before the test case foo-bar. This since the code accidentally sorted test cases on the name of their .ans file, and - < .. Fixes the same bug for samples in markdown statements.

Also adds a check to prevent a test case group from being a sibling to a test case with the same name (e.g. foo/..., foo.in, foo.ans in the same directory).


# Not test classes -- just named that way by the model. Tell pytest not to collect them.
TestCase.__test__ = False # type: ignore[attr-defined]
TestDataGroup.__test__ = False # type: ignore[attr-defined]

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.

My PyTest is a bit rusty, but this looks out of place to me. Shouldn't this be in in the class bodies in model/testdata.py?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's another way to do it. I have a somewhat strong preference to not clutter our production code with test cruft.

Admittedly, for these two classes, I am considering making an exception. But not in this PR.

@gkreitz
gkreitz merged commit 82fcb5a into Kattis:master Nov 5, 2026
7 checks passed
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.

2 participants