Skip to content

Commit

Permalink
fix: ability to reset singleton for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
horw committed Nov 27, 2023
1 parent 26abc25 commit ce9df7f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions idf_build_apps/session_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,10 @@ def set_session_args(*args, **kwargs) -> None:
_session_args = SessionArgs(*args, **kwargs)
else:
warnings.warn('SessionArgs have been set up. Use `get_session_args` to retrieve an instance of this class.')


def reset_singleton() -> None:
global _session_args
if hasattr(SessionArgs, '_instance'):
_session_args = None
del SessionArgs._instance
4 changes: 4 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@
App,
setup_logging,
)
from idf_build_apps.session_args import (
reset_singleton,
)


@pytest.fixture(autouse=True)
def clean_cls_attr():
App.MANIFEST = None
reset_singleton()


@pytest.fixture(autouse=True)
Expand Down

0 comments on commit ce9df7f

Please sign in to comment.