Bump time-machine from 2.17.0 to 2.18.0 (#6113)

* Bump time-machine from 2.17.0 to 2.18.0

Bumps [time-machine](https://github.com/adamchainz/time-machine) from 2.17.0 to 2.18.0.
- [Changelog](https://github.com/adamchainz/time-machine/blob/main/docs/changelog.rst)
- [Commits](https://github.com/adamchainz/time-machine/compare/2.17.0...2.18.0)

---
updated-dependencies:
- dependency-name: time-machine
  dependency-version: 2.18.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix time_machine usage

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Stefan Agner <stefan@agner.ch>
This commit is contained in:
dependabot[bot] 2025-08-20 10:37:29 +02:00 committed by GitHub
parent b49ce96df8
commit 07d8fd006a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 16 deletions

View File

@ -9,7 +9,7 @@ pytest-cov==6.2.1
pytest-timeout==2.4.0
pytest==8.4.1
ruff==0.12.9
time-machine==2.17.0
time-machine==2.19.0
types-docker==7.1.0.20250809
types-pyyaml==6.0.12.20250809
types-requests==2.32.4.20250809

View File

@ -1184,28 +1184,29 @@ async def test_job_scheduled_at(coresys: CoreSys):
self.coresys.jobs.current.stage = "work"
test = TestClass(coresys)
with time_machine.travel(dt):
job, _ = await test.job_scheduler()
started = False
ended = False
job_started = asyncio.Event()
job_ended = asyncio.Event()
async def start_listener(evt_job: SupervisorJob):
nonlocal started
started = started or evt_job.uuid == job.uuid
if evt_job.uuid == job.uuid:
job_started.set()
async def end_listener(evt_job: SupervisorJob):
nonlocal ended
ended = ended or evt_job.uuid == job.uuid
if evt_job.uuid == job.uuid:
job_ended.set()
coresys.bus.register_event(BusEvent.SUPERVISOR_JOB_START, start_listener)
coresys.bus.register_event(BusEvent.SUPERVISOR_JOB_END, end_listener)
async with time_machine.travel(dt):
job, _ = await test.job_scheduler()
await asyncio.sleep(0.2)
coresys.bus.register_event(BusEvent.SUPERVISOR_JOB_START, start_listener)
coresys.bus.register_event(BusEvent.SUPERVISOR_JOB_END, end_listener)
# Advance time to exactly when job should start and wait for completion
async with time_machine.travel(dt + timedelta(seconds=0.1)):
await asyncio.wait_for(
asyncio.gather(job_started.wait(), job_ended.wait()), timeout=1.0
)
assert started
assert ended
assert job.done
assert job.name == "test_job_scheduled_at_job_task"
assert job.stage == "work"