Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lite_bootstrap/bootstrappers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ def _prepare_application(self) -> ApplicationT: ...
def is_ready(self) -> bool: ...

def bootstrap(self) -> ApplicationT:
if self.is_bootstrapped:
return self._prepare_application()
self.is_bootstrapped = True
for one_instrument in self.instruments:
one_instrument.bootstrap()
Expand Down
15 changes: 15 additions & 0 deletions tests/test_free_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,18 @@ def test_teardown_is_idempotent(free_bootstrapper_config: FreeConfig) -> None:
first.teardown.assert_called_once()
second.teardown.assert_called_once()
assert not bootstrapper.is_bootstrapped


def test_bootstrap_is_idempotent(free_bootstrapper_config: FreeConfig) -> None:
bootstrapper = FreeBootstrapper(bootstrap_config=free_bootstrapper_config)

first = MagicMock()
second = MagicMock()
bootstrapper.instruments = [first, second]

bootstrapper.bootstrap()
bootstrapper.bootstrap()

first.bootstrap.assert_called_once()
second.bootstrap.assert_called_once()
assert bootstrapper.is_bootstrapped
Loading