22from .. import logging
33import os
44
5- @mock .patch ("subprocess.call " )
6- def test_forAllLevels (mockSubprocessCall ):
5+ @mock .patch ("syslog.syslog " )
6+ def test_forAllLevels (mockSyslog ):
77 logging .debug ("debug" )
88 logging .info ("info" )
99 logging .warning ("warning" )
1010 logging .error ("error" )
1111 logging .fatal ("fatal" )
1212 logging .exception (Exception ("exception" ))
1313
14- logs = _getLoggedLogs (mockSubprocessCall )
14+ logs = _getLoggedLogs (mockSyslog )
1515 assert logs == [
1616 "[DEBUG] (tests.test_logging) debug" ,
1717 "[INFO] (tests.test_logging) info" ,
@@ -24,12 +24,12 @@ def test_forAllLevels(mockSubprocessCall):
2424 ]
2525
2626@mock .patch ("inspect.stack" )
27- @mock .patch ("subprocess.call " )
28- def test_inspectStackEmpty (mockSubprocessCall , mockInspectStack ):
27+ @mock .patch ("syslog.syslog " )
28+ def test_inspectStackEmpty (mockSyslog , mockInspectStack ):
2929 mockInspectStack .return_value = []
3030 logging .info ("info without module name" )
3131
32- logs = _getLoggedLogs (mockSubprocessCall )
32+ logs = _getLoggedLogs (mockSyslog )
3333 assert logs == [
3434 "[INFO] info without module name"
3535 ]
@@ -56,14 +56,8 @@ def test_printLogs(mockConfigNetwork, mockOpen, mockPrint):
5656# - Helper functions -
5757# --------------------
5858
59- def _getLoggedLogs (mockSubprocessCall ):
60- logs = []
61- for call_args in mockSubprocessCall .call_args_list :
62- args = call_args .args [0 ]
63- print (args )
64- if type (args ) == list and args [0 ] == "logger" :
65- logs .append (args [3 ])
66- return logs
59+ def _getLoggedLogs (mockSyslog ):
60+ return [call_args .args [0 ] for call_args in mockSyslog .call_args_list ]
6761
6862def _getPrintedLines (mockPrint ):
6963 lines = []
0 commit comments