Debian Codegraph @

tests/test_logger.py

raw
1 # Copyright 2018 Facundo Batista, Nicolás Demarchi
2 #
3 # This program is free software: you can redistribute it and/or modify it
4 # under the terms of the GNU General Public License version 3, as published
5 # by the Free Software Foundation.
6 #
7 # This program is distributed in the hope that it will be useful, but
8 # WITHOUT ANY WARRANTY; without even the implied warranties of
9 # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
10 # PURPOSE. See the GNU General Public License for more details.
11 #
12 # You should have received a copy of the GNU General Public License along
13 # with this program. If not, see <http://www.gnu.org/licenses/>.
14 #
15 # For further info, check https://github.com/PyAr/fades
16
17 """Tests for logger related code."""
18 from fades.logger import set_up as log_set_up
19
20
21 def test_salutes_info(logs):
22 """Check saluting handler."""
23 logger = log_set_up(verbose=False, quiet=True)
24 logger.warning("test foobar")
25
26 assert "Hi! This is fades" in logs.info
27 assert "test foobar" in logs.warning
28
29
30 def test_salutes_once(logs):
31 logger = log_set_up(verbose=False, quiet=False)
32 logger.info("test foobar")
33 assert "Hi! This is fades" in logs.info
34 assert "test foobar" in logs.info
35
36 # again, check this time it didn't salute, but original log message is ok
37 logs.reset()
38 logger.info("test barbarroja")
39
40 assert "Hi! This is fades" not in logs.info
41 assert "test barbarroja" in logs.info