[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-taler-util] 30/51: Testing env var GNUNET_LOG.
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-taler-util] 30/51: Testing env var GNUNET_LOG. |
Date: |
Mon, 23 Sep 2019 22:02:21 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository taler-util.
commit 4f37ff122681b5c537e6b8ced56ac469470e80e4
Author: Marcello Stanisci <address@hidden>
AuthorDate: Thu Feb 7 14:14:37 2019 +0100
Testing env var GNUNET_LOG.
---
python/log/gnunet_log.py | 2 +-
python/log/test_ut.py | 24 ++++++++++++++++++++++--
2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/python/log/gnunet_log.py b/python/log/gnunet_log.py
index 770f995..8b5134a 100755
--- a/python/log/gnunet_log.py
+++ b/python/log/gnunet_log.py
@@ -23,7 +23,7 @@ class LogDefinition:
interval_re = "^([0-9]+)(-([0-9]+))?$"
match = re.match(interval_re, line_interval)
if match:
- return dict(min=match.group(1), max=match.group(3))
+ return dict(min=int(match.group(1)), max=int(match.group(3)))
# just match every line if bad interval was provided.
return dict(min=0, max=float("inf"))
diff --git a/python/log/test_ut.py b/python/log/test_ut.py
index 6227d4c..2b973f5 100755
--- a/python/log/test_ut.py
+++ b/python/log/test_ut.py
@@ -31,6 +31,13 @@ import os
from mock import patch
import logging
+# How the logging module defines loglevels.
+#
+# ERROR = 40
+# WARNING = 30
+# INFO = 20
+# DEBUG = 10
+
def clean_env():
if os.environ.get("GNUNET_FORCE_LOG"):
del os.environ["GNUNET_FORCE_LOG"]
@@ -54,10 +61,23 @@ class TestGnunetLog(TestCase):
# (WARNING) will apply)!
@patch("logging.Logger.setLevel")
@patch("logging.basicConfig")
- def test_no_env_and_no_setup(self, mocked_basicconfig, mocked_setLevel):
+ def test_no_env_and_no_setup(self, mocked_basicConfig, mocked_setLevel):
# Double-check no env variable gets in the way.
assert None == os.environ.get("GNUNET_FORCE_LOG")
assert None == os.environ.get("GNUNET_LOG")
- gl = GL("mock-style")
+ gl = GL("gnunet-pylog")
gl.log("msg", gl.INFO)
mocked_setLevel.assert_called_with(level=logging.INFO)
+
+
+ # This function tests the case where *only* the GNUNET_LOG
+ # env variable is set -- not even the manual setup of the
+ # loglevel is put in place.
+ @patch("logging.Logger.setLevel")
+ @patch("logging.basicConfig")
+ def test_non_forced_env(self, mocked_basicConfig, mocked_setLevel):
+ assert None == os.environ.get("GNUNET_FORCE_LOG")
+ os.environ["GNUNET_LOG"] =
"gnunet-pylog;test_ut.py;test_non_forced_env;60-90;ERROR"
+ gl = GL("gnunet-pylog")
+ gl.log("msg", gl.DEBUG)
+ mocked_setLevel.assert_called_with(level=logging.ERROR)
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [GNUnet-SVN] [taler-taler-util] 26/51: 4453. Check against further fields (filename, func, lineno), (continued)
- [GNUnet-SVN] [taler-taler-util] 26/51: 4453. Check against further fields (filename, func, lineno), gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 17/51: 4453., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 24/51: fix filename extraction., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 18/51: 4453., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 20/51: 4453., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 22/51: 4453, use regex., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 15/51: Update amount., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 21/51: 4453., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 23/51: fetch caller's metadata., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 29/51: rename function, gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 30/51: Testing env var GNUNET_LOG.,
gnunet <=
- [GNUnet-SVN] [taler-taler-util] 32/51: 4453. Testing mixed situation,, gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 37/51: fix after file rename, gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 38/51: 4453. Test GNUNET_FORCE_LOGFILE., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 50/51: Make tests work again., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 33/51: 4453. Test manual loglevel setup and nonforced env., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 27/51: syntax, gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 34/51: 4453. Test for GNUNET_LOG and GNUNET_FORCE_LOG both defined., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 39/51: Log: fix line interval parsing (care about one number case.), gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 31/51: 4453. Test only manual loglevel setup., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 28/51: Testing 4453 with unittest. First batch., gnunet, 2019/09/23