From 1f26b3090c29e2d804ae652af64f39d133857d89 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 26 Aug 2015 20:38:29 +0200 Subject: [PATCH] tests: Add _debug_log test for BaseKeyParser. --- tests/unit/keyinput/test_basekeyparser.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/unit/keyinput/test_basekeyparser.py b/tests/unit/keyinput/test_basekeyparser.py index 36cf0025b..723a2df11 100644 --- a/tests/unit/keyinput/test_basekeyparser.py +++ b/tests/unit/keyinput/test_basekeyparser.py @@ -41,6 +41,24 @@ def mock_timer(monkeypatch, stubs): stubs.FakeTimer) +class TestDebugLog: + + """Make sure _debug_log only logs when do_log is set.""" + + def test_log(self, caplog): + kp = basekeyparser.BaseKeyParser(0) + kp._debug_log('foo') + assert len(caplog.records()) == 1 + record = caplog.records()[0] + assert record.message == 'foo' + + def test_no_log(self, caplog): + kp = basekeyparser.BaseKeyParser(0) + kp.do_log = False + kp._debug_log('foo') + assert not caplog.records() + + class TestSplitCount: """Test the _split_count method.