From 726628cc4c953e5cfb2aaefd9aa6f461fba27fd6 Mon Sep 17 00:00:00 2001 From: Zhiyi Wu Date: Sun, 11 Dec 2022 00:21:46 +0000 Subject: [PATCH] enable full logging with -v (PR #26) * fix #25 * enable full logging at INFO when -v (verbose) is requested * Update CHANGES --- CHANGES | 11 ++++++++++- flamel/flamel.py | 5 ++++- flamel/tests/test_flamel.py | 12 ++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 5d2116f..9a4c648 100644 --- a/CHANGES +++ b/CHANGES @@ -13,15 +13,24 @@ The rules for this file: * release numbers follow "Semantic Versioning" https://semver.org ------------------------------------------------------------------------------ +2022-??-?? xiki-tempula + + * 0.3.2 + +Fixes + +- enable logger output for -v (issue #25) + 2022-12-06 xiki-tempula, hejamu * 0.3.1 - Fixes +Fixes - Handle 0 as input to the forwrev (Issue #18/ PR #20). + 2022-11-09 xiki-tempula, orbeckst * 0.3.0 diff --git a/flamel/flamel.py b/flamel/flamel.py index d4b1d66..8709566 100644 --- a/flamel/flamel.py +++ b/flamel/flamel.py @@ -173,7 +173,10 @@ def main(): # Print the logging to the console if args.verbose: - logging.getLogger().addHandler(logging.StreamHandler()) + logging.basicConfig( + level=logging.INFO, + handlers=[logging.StreamHandler()], + ) if args.output_directory == "": out = args.datafile_directory diff --git a/flamel/tests/test_flamel.py b/flamel/tests/test_flamel.py index 28f0012..361d0b1 100644 --- a/flamel/tests/test_flamel.py +++ b/flamel/tests/test_flamel.py @@ -6,6 +6,7 @@ import sys import pathlib import pickle +import subprocess import pytest from numpy.testing import assert_approx_equal @@ -47,6 +48,17 @@ def test_dhdl_TI(self, setup): assert (setup / "dhdl_TI.pdf").exists() +def test_verbose(): + p = subprocess.Popen( + ["flamel", "-v"], stdout=subprocess.PIPE, stderr=subprocess.PIPE + ) + out, err = p.communicate() + assert ( + "INFO:alchemlyb.workflows.ABFE:Initialise Alchemlyb ABFE Workflow" + in err.decode() + ) + + class TestFlamelOptions(TestFlamel): @staticmethod @pytest.fixture(scope="session")