Exemple #1
0
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 ''
Exemple #2
0
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 ''
Exemple #3
0
    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
Exemple #4
0
    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
Exemple #5
0
  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
Exemple #6
0
  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