From f087f527cc62bb3af6a0d620cf693f75e2cf4334 Mon Sep 17 00:00:00 2001 From: Qubasa Date: Thu, 11 Jan 2024 22:46:29 +0100 Subject: [PATCH] Removed duplicate logging messages --- pkgs/clan-cli/clan_cli/cmd.py | 2 +- pkgs/clan-cli/tests/conftest.py | 11 +++++++++++ pkgs/clan-cli/tests/helpers/cli.py | 8 +++----- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/pkgs/clan-cli/clan_cli/cmd.py b/pkgs/clan-cli/clan_cli/cmd.py index 53a5a79c1..cafff8824 100644 --- a/pkgs/clan-cli/clan_cli/cmd.py +++ b/pkgs/clan-cli/clan_cli/cmd.py @@ -60,7 +60,7 @@ def run( check: bool = True, error_msg: str | None = None, ) -> CmdOut: - glog.debug(f"running command: {shlex.join(cmd)}. Caller: {get_caller()}") + glog.debug(f"$: {shlex.join(cmd)} \nCaller: {get_caller()}") # Start the subprocess process = subprocess.Popen( cmd, diff --git a/pkgs/clan-cli/tests/conftest.py b/pkgs/clan-cli/tests/conftest.py index 04c1d6e68..da275fe0a 100644 --- a/pkgs/clan-cli/tests/conftest.py +++ b/pkgs/clan-cli/tests/conftest.py @@ -5,6 +5,7 @@ from pathlib import Path import pytest +from clan_cli.custom_logger import setup_logging from clan_cli.nix import nix_shell sys.path.append(os.path.join(os.path.dirname(__file__), "helpers")) @@ -21,6 +22,16 @@ pytest_plugins = [ ] +# Executed on pytest session start +def pytest_sessionstart(session: pytest.Session) -> None: + # This function will be called once at the beginning of the test session + print("Starting pytest session") + # You can access the session config, items, testsfailed, etc. + print(f"Session config: {session.config}") + + setup_logging(level="DEBUG") + + # fixture for git_repo @pytest.fixture def git_repo(tmp_path: Path) -> Path: diff --git a/pkgs/clan-cli/tests/helpers/cli.py b/pkgs/clan-cli/tests/helpers/cli.py index c6fdd3865..2cba28aca 100644 --- a/pkgs/clan-cli/tests/helpers/cli.py +++ b/pkgs/clan-cli/tests/helpers/cli.py @@ -3,7 +3,7 @@ import logging import shlex from clan_cli import create_parser -from clan_cli.custom_logger import get_caller, setup_logging +from clan_cli.custom_logger import get_caller log = logging.getLogger(__name__) @@ -12,10 +12,8 @@ class Cli: def run(self, args: list[str]) -> argparse.Namespace: parser = create_parser(prog="clan") parsed = parser.parse_args(args) - setup_logging(logging.DEBUG) - cmd = shlex.join(["clan", "--debug", *args]) - log.debug(f"$ {cmd}") - log.debug(f"Caller {get_caller()}") + cmd = shlex.join(["clan", *args]) + log.debug(f"$ {cmd} \nCaller: {get_caller()}") if hasattr(parsed, "func"): parsed.func(parsed) return parsed