Skip to content

do not raise exceptions other than ParseError in the unit tests - #887

Merged
andlaus merged 1 commit into
cantools:masterfrom
andlaus:fix_unit_tests_format_probing
Nov 20, 2026
Merged

andlaus merged 1 commit into
cantools:masterfrom
andlaus:fix_unit_tests_format_probing

Conversation

@andlaus

@andlaus andlaus commented Nov 17, 2026

Copy link
Copy Markdown
Member

IMO this demonstrates quite well why we kept the fallback code for non-ParseErrors...

IMO this demonstrates quite well why we kept the fallback code for
non-`ParseError`s...

Signed-off-by: Andreas Lauser <[email protected]>
Approved-by: Alexander Walz <[email protected]>
@andlaus

andlaus commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

@Poseidonas: since you opened #827, it would be great if you gave this one a spin.

@Poseidonas

Copy link
Copy Markdown
Contributor

I gave it a spin. For the four rejects_word tests it does what it says: InvalidOperation becomes a ValueError, which is in the probe tuple, so the warning from #827 goes away. Across 9768 mutated inputs built from tests/files, it changes exactly those 50 cases and nothing else. The suite passes.

It leaves the other builtin exceptions in the same two functions: Infinity in an INT, HEX or ENUM attribute raises OverflowError (with the warning), and NaN raises ValueError.

It overlaps with #830, which changes the same lines of to_int/to_float to raise ParseError, and covers the cases above. On top of #830 the ValueError version is reported as a bug by its test fixture, so the two need one direction. If you prefer to merge this one first, I will adapt #830 to it.

@andlaus

andlaus commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

If you prefer to merge this one first, I will adapt #830 to it.

Thanks. I need a bit more time to brood over #830 as I consider it to be somewhat risky, so I'll merge this one first. IOW it would be great if you adapted #830.

@andlaus
andlaus merged commit a2a35a6 into cantools:master Nov 20, 2026
38 of 39 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