def _get_source_safely(obj): try: return inspect.getsource(obj) except Exception: # pylint: disable=broad-except logs.log_once( _LOG.warning, 'Unable to load source code for %s. Only logging this once.', obj) return ''
def test_log_once_utf8(self): mock_log = mock.Mock() for _ in range(10): logs.log_once(mock_log, u'状态是', 'arg1') assert mock_log.call_count == 1
def test_log_once(self): mock_log = mock.Mock() for _ in range(10): logs.log_once(mock_log, 'Message 1', 'arg1') assert mock_log.call_count == 1