test_log_utils.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 from mock import patch
5 from nose.tools import assert_equal
6 import unittest
7 
8 from jsk_topic_tools.log_utils import _log_msg_with_called_location
9 from jsk_topic_tools.log_utils import jsk_logdebug
10 from jsk_topic_tools.log_utils import jsk_loginfo
11 from jsk_topic_tools.log_utils import jsk_logwarn
12 from jsk_topic_tools.log_utils import jsk_logerr
13 from jsk_topic_tools.log_utils import jsk_logfatal
14 from jsk_topic_tools.log_utils import warn_no_remap
15 
16 
17 @patch('rospy.get_name')
19  mock_get_name.return_value = '/spam'
20  msg = _log_msg_with_called_location('spam')
21  assert_equal(msg, '[/spam] [patched] spam')
22 
23 
24 class TestJSKLogXXX(unittest.TestCase):
25 
26  @patch('rospy.logdebug')
27  @patch('rospy.get_name')
28  def test_jsk_logdebug(self, mock_get_name, mock_log):
29  mock_get_name.return_value = '/spam'
30  jsk_logdebug('spam')
31  mock_log.assert_called_with('[/spam] [TestJSKLogXXX::test_jsk_logdebug] spam')
32 
33  @patch('rospy.loginfo')
34  @patch('rospy.get_name')
35  def test_jsk_loginfo(self, mock_get_name, mock_log):
36  mock_get_name.return_value = '/spam'
37  jsk_loginfo('spam')
38  mock_log.assert_called_with('[/spam] [TestJSKLogXXX::test_jsk_loginfo] spam')
39 
40  @patch('rospy.logwarn')
41  @patch('rospy.get_name')
42  def test_jsk_logwarn(self, mock_get_name, mock_log):
43  mock_get_name.return_value = '/spam'
44  jsk_logwarn('spam')
45  mock_log.assert_called_with('[/spam] [TestJSKLogXXX::test_jsk_logwarn] spam')
46 
47  @patch('rospy.logerr')
48  @patch('rospy.get_name')
49  def test_jsk_logerr(self, mock_get_name, mock_log):
50  mock_get_name.return_value = '/spam'
51  jsk_logerr('spam')
52  mock_log.assert_called_with('[/spam] [TestJSKLogXXX::test_jsk_logerr] spam')
53 
54  @patch('rospy.logfatal')
55  @patch('rospy.get_name')
56  def test_jsk_logfatal(self, mock_get_name, mock_log):
57  mock_get_name.return_value = '/spam'
58  jsk_logfatal('spam')
59  mock_log.assert_called_with('[/spam] [TestJSKLogXXX::test_jsk_logfatal] spam')
60 
61 
62 @patch('rospy.logwarn')
63 @patch('rospy.names.get_resolved_mappings')
64 @patch('rosgraph.names.resolve_name')
65 @patch('rospy.get_name')
66 def test_warn_no_remap(mock_get_name, mock_resolve_name,
67  mock_get_resolved_mappings, mock_log):
68  mock_get_name.return_value = '/spam'
69  mock_resolve_name.return_value = '/spam/input'
70  mock_get_resolved_mappings.return_value = {}
71  warn_no_remap('~input')
72  mock_log.assert_called_with("[/spam] '~input' has not been remapped.")
def _log_msg_with_called_location(msg)
Definition: log_utils.py:13
def test_warn_no_remap(mock_get_name, mock_resolve_name, mock_get_resolved_mappings, mock_log)
def test__log_msg_with_called_location(mock_get_name)
def test_jsk_logfatal(self, mock_get_name, mock_log)
def warn_no_remap(names)
Definition: log_utils.py:97
def test_jsk_logerr(self, mock_get_name, mock_log)
def test_jsk_logdebug(self, mock_get_name, mock_log)
def test_jsk_logwarn(self, mock_get_name, mock_log)
def test_jsk_loginfo(self, mock_get_name, mock_log)


jsk_topic_tools
Author(s): Kei Okada , Yusuke Furuta
autogenerated on Tue Feb 6 2018 03:45:19