Add tests for EnumParityTest#242
Merged
Merged
Conversation
This test utility is part of the public interface, a tool offered to downstream users, so it should be properly tested. Added tests cover: - Positive: a correct enum passes every inherited check (including no-op `deprecated_members`/`absent_members`). - Forward-compat: a protobuf value not yet mirrored in Python is tolerated. - Failure detection: value mismatch and name mismatch make the relevant checks raise `AssertionError`. - `absent_members`: passes when a member is removed from Python but kept in protobuf; fails when a "removed" member is still present. - `deprecated_members`: warns on access yet satisfies parity; and is caught when a listed member isn't actually deprecated. - `silence_deprecations`: a fully-deprecated enum with `@deprecated` converters (mirrors the real `EvChargerType`/`BatteryType`) round-trips cleanly. - `from_proto` unknown: rejects a converter returning a non-`int`. - Context managers `_maybe_ignore_deprecation` / `_maybe_silence_converter_deprecation`: suppress warnings only when configured. - `pytest_generate_tests`: parametrizes `pb_name`/`member` correctly and ignores unrelated fixtures. - `test_proto_enum_matches_enum_value(): detects value mismatches (this is currently not properly checked by `EnumParityTest`). Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
Fixed `EnumParityTest` so protobuf values whose Python member name exists with a different number fail parity checks instead of being treated as unmirrored protobuf values. Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
Marenz
approved these changes
Jul 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This test utility is part of the public interface, a tool offered to downstream users, so it should be properly tested.
This PR adds tests cover for:
deprecated_members/absent_members).AssertionError.absent_members: passes when a member is removed from Python but kept in protobuf; fails when a "removed" member is still present.deprecated_members: warns on access yet satisfies parity; and is caught when a listed member isn't actually deprecated.silence_deprecations: a fully-deprecated enum with@deprecatedconverters (mirrors the realEvChargerType/BatteryType) round-trips cleanly.from_protounknown: rejects a converter returning a non-int._maybe_ignore_deprecation/_maybe_silence_converter_deprecation: suppress warnings only when configured.pytest_generate_tests: parametrizespb_name/membercorrectly and ignores unrelated fixtures.test_proto_enum_matches_enum_value(): detects value mismatches (this is currently not properly checked byEnumParityTest`).It also fixes
EnumParityTestso protobuf values whose Python member name exists with a different number fail parity checks instead of being treated as unmirrored protobuf values.