When testing timer entrypoints (especially now that we have the “eager” argument), I’d like to fire at all so that I can use entrypoint_hook
and call it when I want.
So if I have a service
class TestService:
name = "test_service"
@timer(10, eager=True)
def run(self):
print("yeah")
and a test like this:
def test_service(container_factory):
container = container_factory(TestService, {})
container.start()
with entrypoint_hook(container, "run") as hook:
hook()
will cause run to be called twice (since it’s called as soon as the container starts as well as within the entrypoint hook. Is there any “nice” way to work around this?
I can do awful stuff like this:
for entrypoint in list(container.entrypoints):
if entrypoint.method_name == 'run':
entrypoint.eager = False # hack so that it doesn't start right away
but I imagine that is not the nicest way of dealing with this