Repository navigation
Add a test for services defined in closures - #934
Merged
craigbarratt merged 1 commit intoDec 1, 2026
Merged
Conversation
craigbarratt
approved these changes
Dec 1, 2026
craigbarratt
left a comment
Member
There was a problem hiding this comment.
Thanks @jfriend00, a useful test. It passes merged with current master, and it fails if ServiceDecorator.stop() doesn't remove the service. Approving.
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.
Following the discussion in #896, I moved my per-instance triggers into trigger factories: a method called from
__init__defines the triggers and keeps them in an attribute, as in the class example now in the "Trigger Closures" section of the docs. I wanted per-instance services the same way, each named from the object it serves, for example one per thermostat. That works on 2.1.1 and on master, but no current test defines a@serviceinside a function or class, so this adds one, modeled ontest_trigger_closures.test_service_closurescovers:__init__, each named with an f-string from its own variablesIt passes on master at ad31306. Removing the
Function.service_register()call inServiceDecorator.start(), or theFunction.service_remove()call instop(), makes it fail. It was run on Windows, with local stand-ins for Home Assistant's Unix-only imports, so CI will be its first run on Linux.