core: add tmp_config helper for test & adhoc patching

bluemaestro: cleanup tests
This commit is contained in:
Dima Gerasimov 2021-02-18 22:40:05 +00:00 committed by karlicoss
parent 42399f6250
commit 5313984d8f
3 changed files with 21 additions and 17 deletions

View file

@ -40,3 +40,11 @@ def override_config(config: F) -> Iterator[F]:
# ugh. __dict__ of type objects isn't writable..
for k, v in orig_properties.items():
setattr(config, k, v)
# helper for tests? not sure if could be useful elsewhere
@contextmanager
def tmp_config():
import my.config as C
with override_config(C):
yield C # todo not sure?