summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2018-11-17 13:40:05 +0100
committerLars-Dominik Braun <lars@6xq.net>2018-11-17 13:40:05 +0100
commit22c1d384c1951f1ed45773f92804f9a1c69419e2 (patch)
treefe8ec2e05f688ebce90a8d88391bf68a83565e5b
parent990bb56afd0c537aa836deec2469b50d737c8eb9 (diff)
downloadcrocoite-22c1d384c1951f1ed45773f92804f9a1c69419e2.tar.gz
crocoite-22c1d384c1951f1ed45773f92804f9a1c69419e2.tar.bz2
crocoite-22c1d384c1951f1ed45773f92804f9a1c69419e2.zip
logger: Add more tests
-rw-r--r--crocoite/logger.py2
-rw-r--r--crocoite/test_logger.py26
2 files changed, 25 insertions, 3 deletions
diff --git a/crocoite/logger.py b/crocoite/logger.py
index 1a269b1..e69df5e 100644
--- a/crocoite/logger.py
+++ b/crocoite/logger.py
@@ -85,7 +85,7 @@ class Logger:
self.consumer.remove (consumer)
class Consumer:
- def __call__ (self, level, *args, **kwargs):
+ def __call__ (self, level, *args, **kwargs): # pragma: no cover
raise NotImplementedError ()
class NullConsumer (Consumer):
diff --git a/crocoite/test_logger.py b/crocoite/test_logger.py
index 8a34aab..3af1321 100644
--- a/crocoite/test_logger.py
+++ b/crocoite/test_logger.py
@@ -1,9 +1,9 @@
import pytest
-from .logger import Logger, Consumer, NullConsumer
+from .logger import Logger, Consumer, NullConsumer, Level, DatetimeConsumer
@pytest.fixture
def logger ():
- return Logger (consumer=[NullConsumer ()])
+ return Logger (consumer=[NullConsumer (), DatetimeConsumer ()])
class QueueConsumer (Consumer):
def __init__ (self):
@@ -58,3 +58,25 @@ def test_consumer (logger):
assert ret['foo'] == 'bar'
assert ret['inherit'] == 1
+def test_multiarg (logger):
+ # single argument
+ ret = logger.debug('maybe', foo='bar')
+ assert ret['msg'] == 'maybe'
+ assert ret['foo'] == 'bar'
+
+ # multi arguments
+ ret = logger.debug('may', 'be', foo='bar')
+ assert ret['msg'] == ('may', 'be')
+ assert ret['foo'] == 'bar'
+
+def test_call (logger):
+ for level in ('debug', Level.DEBUG):
+ ret = logger(level, 'arg1', 'arg2', foo='bar')
+ assert ret['level'] == Level.DEBUG
+ assert ret['msg'] == ('arg1', 'arg2')
+ assert ret['foo'] == 'bar'
+
+def test_datetime (logger):
+ ret = logger.debug()
+ assert 'date' in ret
+