gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-taler-util] 28/51: Testing 4453 with unittest. First


From: gnunet
Subject: [GNUnet-SVN] [taler-taler-util] 28/51: Testing 4453 with unittest. First batch.
Date: Mon, 23 Sep 2019 22:02:19 +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 4a606080c1994e198d42f296c99e8f70d46be582
Author: Marcello Stanisci <address@hidden>
AuthorDate: Thu Feb 7 13:57:05 2019 +0100

    Testing 4453 with unittest.  First batch.
---
 python/amount/README             |  4 +++
 python/log/{test.py => test.old} |  0
 python/log/test_ut.py            | 63 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 67 insertions(+)

diff --git a/python/amount/README b/python/amount/README
new file mode 100644
index 0000000..2990bfe
--- /dev/null
+++ b/python/amount/README
@@ -0,0 +1,4 @@
+Run the tests with:
+
+# Just from this directory.
+$ python3 -m unittest
diff --git a/python/log/test.py b/python/log/test.old
similarity index 100%
rename from python/log/test.py
rename to python/log/test.old
diff --git a/python/log/test_ut.py b/python/log/test_ut.py
new file mode 100755
index 0000000..6d84190
--- /dev/null
+++ b/python/log/test_ut.py
@@ -0,0 +1,63 @@
+#  This file is part of TALER
+#  (C) 2019 TALER SYSTEMS
+#
+#  This library is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU Lesser General Public
+#  License as published by the Free Software Foundation; either
+#  version 2.1 of the License, or (at your option) any later
+#  version.
+#
+#  This library is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU Lesser General Public License for more details.
+#
+#  You should have received a copy of the GNU Lesser General Public
+#  License along with this library; if not, write to the Free
+#  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+#  Boston, MA  02110-1301  USA
+#
+#  @author Marcello Stanisci
+#  @version 0.0
+#  @repository https://git.taler.net/copylib.git/
+#  This code is "copylib", it is versioned under the Git repository
+#  mentioned above, and it is meant to be manually copied into any
+#  project which might need it.
+
+
+from unittest import TestCase
+from gnunet_log import GnunetLogger as GL
+import os
+from mock import patch
+import logging
+
+def clean_env():
+    if os.environ.get("GNUNET_FORCE_LOG"):
+        del os.environ["GNUNET_FORCE_LOG"]
+    if os.environ.get("GNUNET_LOG"):
+        del os.environ["GNUNET_LOG"]
+    if os.environ.get("GNUNET_FORCE_LOGFILE"):
+        del os.environ["GNUNET_FORCE_LOGFILE"]
+
+class TestGnunetLog(TestCase):
+    def setUp(self):
+        clean_env()
+
+    # This function tests the very basic case, where no
+    # env variable is set and no explicit loglevel is given
+    # via the "setup()" method.  The expected result is that
+    # the level is set to INFO.
+    #
+    # NOTE: no logs will appear on screen, as the setLevel
+    # function is mocked (and the level specified won't be
+    # made effective -- rather, only the very default level
+    # (WARNING) will apply)!
+    @patch("logging.Logger.setLevel")
+    @patch("logging.basicConfig")
+    def test_env(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.log("msg", gl.INFO)
+        mocked_setLevel.assert_called_with(level=logging.INFO)

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]