MCPcopy
hub / github.com/encode/uvicorn / test_base_reloader_run

Function test_base_reloader_run

tests/supervisors/test_reload.py:357–385  ·  view source on GitHub ↗
(tmp_path: Path)

Source from the content-addressed store, hash-verified

355
356
357def test_base_reloader_run(tmp_path: Path):
358 calls: list[str] = []
359 step = 0
360
361 class CustomReload(BaseReload):
362 def startup(self):
363 calls.append("startup")
364
365 def restart(self):
366 calls.append("restart")
367
368 def shutdown(self):
369 calls.append("shutdown")
370
371 def should_restart(self):
372 nonlocal step
373 step += 1
374 if step == 1:
375 return None
376 elif step == 2:
377 return [tmp_path / "foobar.py"]
378 else:
379 raise StopIteration()
380
381 config = Config(app="tests.test_config:asgi_app", reload=True)
382 reloader = CustomReload(config, target=run, sockets=[])
383 reloader.run()
384
385 assert calls == ["startup", "restart", "shutdown"]
386
387
388def test_base_reloader_should_exit(tmp_path: Path):

Callers

nothing calls this directly

Calls 3

ConfigClass · 0.90
CustomReloadClass · 0.85
runMethod · 0.45

Tested by

no test coverage detected