From f8e6bfc52c23e209696152ce060a9b139dbd832b Mon Sep 17 00:00:00 2001 From: kraanzu Date: Sat, 16 Nov 2024 10:58:43 +0530 Subject: [PATCH] fix: dont load user config if running under pytest --- dooit/ui/api/plug.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/dooit/ui/api/plug.py b/dooit/ui/api/plug.py index bf5f1b93..380be21d 100644 --- a/dooit/ui/api/plug.py +++ b/dooit/ui/api/plug.py @@ -1,5 +1,6 @@ -from functools import partial +import os import sys +from functools import partial from collections import defaultdict from pathlib import Path from typing import TYPE_CHECKING, Callable, List, Type @@ -24,6 +25,10 @@ DEFAULT_CONFIG = BASE_PATH / "utils" / "default_config.py" +def is_running_under_pytest() -> bool: + return "PYTEST_CURRENT_TEST" in os.environ + + class PluginManager: def __init__(self, api: "DooitAPI") -> None: self.events: defaultdict[Type[DooitEvent], List[Callable]] = defaultdict(list) @@ -33,6 +38,9 @@ def __init__(self, api: "DooitAPI") -> None: def scan(self): load_file(self, DEFAULT_CONFIG) + if is_running_under_pytest(): + return + load_file(self, CONFIG_FOLDER / "config.py") def _update_dooit_value(self, obj, *params):