diff --git a/src/lvmopstools/actor.py b/src/lvmopstools/actor.py index 52b4b84..7ab52c0 100644 --- a/src/lvmopstools/actor.py +++ b/src/lvmopstools/actor.py @@ -79,7 +79,18 @@ def wrapper(added_enum): joined[item.name] = item.value for item in added_enum: joined[item.name] = item.value - return enum.Enum(added_enum.__name__, joined) + + new_enum_class = enum.Enum(added_enum.__name__, joined) + + # Add methods from the inherited class. + for attr in inherited_enum.__dict__: + if attr.startswith("__"): + continue + if hasattr(new_enum_class, attr): + continue + setattr(new_enum_class, attr, getattr(inherited_enum, attr)) + + return new_enum_class return wrapper diff --git a/tests/test_actor.py b/tests/test_actor.py index 281b8d8..7652ffa 100644 --- a/tests/test_actor.py +++ b/tests/test_actor.py @@ -37,6 +37,8 @@ class ExtraErrorCodes(enum.Enum): assert hasattr(ExtraErrorCodes, "SOME_FAILURE_MODE") assert hasattr(ExtraErrorCodes, "UNKNOWN") + assert hasattr(ExtraErrorCodes, "get_error_code") + def test_verify_error_codes_fails(): with pytest.raises(ValueError):