Skip to content

Commit

Permalink
Merge pull request #955 from tue-robotics/feature/import_test
Browse files Browse the repository at this point in the history
robot_skills: add import and doctest test
  • Loading branch information
LarsJanssenTUe committed Dec 14, 2019
2 parents 029280e + f32b09e commit cc9514a
Show file tree
Hide file tree
Showing 23 changed files with 46 additions and 47 deletions.
21 changes: 4 additions & 17 deletions robot_skills/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,8 @@ find_package(catkin REQUIRED COMPONENTS

catkin_python_setup()

# ------------------------------------------------------------------------------------------------
# CATKIN EXPORT
# ------------------------------------------------------------------------------------------------
catkin_package()

catkin_package(
# INCLUDE_DIRS include
# LIBRARIES bla
# CATKIN_DEPENDS other_catkin_pkg
# DEPENDS system_lib
)

# ------------------------------------------------------------------------------------------------
# BUILD
# ------------------------------------------------------------------------------------------------

include_directories(
${catkin_INCLUDE_DIRS}
)
if (CATKIN_ENABLE_TESTING)
catkin_add_nosetests(test)
endif()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions robot_skills/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<depend>hmi</depend>
<depend>hmi_msgs</depend>
<depend>people_recognition_msgs</depend>
<depend>python_orocos_kdl</depend>
<depend>rgbd_msgs</depend>
<depend>rospy</depend>
<depend>smach</depend>
Expand All @@ -38,5 +39,7 @@
<depend>visualization_msgs</depend>

<exec_depend>python-mock</exec_depend>

<test_depend>test_tools</test_depend>

</package>
6 changes: 3 additions & 3 deletions robot_skills/src/robot_skills/arms.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,12 @@ class Arm(RobotPart):
Use left or right to get arm while running from the python console
Examples:
>>> left.send_goal(0.265, 1, 0.816, 0, 0, 0, 60)
>>> left.send_goal(0.265, 1, 0.816, 0, 0, 0, 60) # doctest: +SKIP
or Equivalently:
>>> left.send_goal(px=0.265, py=1, pz=0.816, yaw=0, pitch=0, roll=0, time_out=60, pre_grasp=False, frame_id='/amigo/base_link')
>>> left.send_goal(px=0.265, py=1, pz=0.816, yaw=0, pitch=0, roll=0, time_out=60, pre_grasp=False, frame_id='/amigo/base_link') # doctest: +SKIP
#To open left gripper
>>> left.send_gripper_goal_open(10)
>>> left.send_gripper_goal_open(10) # doctest: +SKIP
"""
def __init__(self, robot_name, tf_listener, get_joint_states, side):
"""
Expand Down
7 changes: 0 additions & 7 deletions robot_skills/src/robot_skills/hero.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,3 @@ def move_to_hmi_pose(self):
arm.send_joint_goal('arm_out_of_way', 0.0)
self.base.force_drive(0, 0, rotation_speed, rotation_duration)
arm.wait_for_motion_done()


if __name__ == "__main__":
rospy.init_node("hero")

import doctest
doctest.testmod()
4 changes: 2 additions & 2 deletions robot_skills/src/robot_skills/mockbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,10 @@ class Mockbot(robot.Robot):
which wont be needed
# I want a blind and mute Mockbot!
>>> Mockbot(['perception', 'speech'])
>>> Mockbot(['perception', 'speech']) # doctest: +SKIP
# I want a full fledged, awesome Mockbot
>>> Mockbot()
>>> Mockbot() # doctest: +SKIP
"""
def __init__(self, *args, **kwargs):
robot_name = "mockbot"
Expand Down
7 changes: 0 additions & 7 deletions robot_skills/src/robot_skills/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,10 +407,3 @@ def _collect_available(values, test_func):
if test_func(value):
founds.add(value)
return founds


if __name__ == "__main__":
rospy.init_node("robot")

import doctest
doctest.testmod()
3 changes: 2 additions & 1 deletion robot_skills/src/robot_skills/util/kdl_conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def extractVectorStamped(self):
:returns VectorStamped
>>> fs = FrameStamped(kdl.Frame(kdl.Rotation.Quaternion(1, 0, 0, 0), kdl.Vector(1, 2, 3)), "/map")
>>> fs.extractVectorStamped()
[ 1, 2, 3] @ /map
VectorStamped([ 1, 2, 3] @ /map)
"""
return deepcopy(VectorStamped(frame_id=self.frame_id, vector=self.frame.p))

Expand Down Expand Up @@ -268,6 +268,7 @@ def kdl_vector_stamped_to_point_stamped(vector_stamped):
vector_stamped.vector.z())
return ps


if __name__ == "__main__":
import doctest
doctest.testmod()
12 changes: 6 additions & 6 deletions robot_skills/src/robot_skills/util/msg_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ def Point(x=0, y=0, z=0):

def Header(frame_id="/map", stamp=None):
"""Make a Header
>>> h = Header("/base_link")
>>> assert h.stamp.secs > 0
>>> assert h.stamp.nsecs > 0
>>> h = Header("/base_link") # doctest: +SKIP
>>> assert h.stamp.secs > 0 # doctest: +SKIP
>>> assert h.stamp.nsecs > 0 # doctest: +SKIP
"""
if not stamp:
_time = rospy.Time.now()
Expand Down Expand Up @@ -61,7 +61,7 @@ def Quaternion(x=0, y=0, z=0, w=0, roll=0, pitch=0, yaw=0):
def Pose(x=0, y=0, z=0, phi=0, roll=0, pitch=0, yaw=0):
"""
>>> pose = Pose(yaw=0.5)
>>> pose
>>> pose # doctest: +NORMALIZE_WHITESPACE
position:
x: 0
y: 0
Expand Down Expand Up @@ -89,8 +89,8 @@ def PoseStamped(x=0, y=0, z=0, phi=0,
frame_id="/map", stamp=None, pointstamped=None):
"""Build a geometry_msgs.msgs.PoseStamped from any number of arguments.
Each value defaults to 0
>>> ps = PoseStamped(yaw=0.5)
>>> ps.pose
>>> ps = PoseStamped(yaw=0.5) # doctest: +SKIP
>>> ps.pose # doctest: +SKIP
position:
x: 0
y: 0
Expand Down
1 change: 0 additions & 1 deletion robot_skills/src/robot_skills/util/shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,4 @@ def shape_from_entity_info(e):

if __name__ == "__main__":
import doctest

doctest.testmod()
1 change: 0 additions & 1 deletion robot_skills/src/robot_skills/util/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,5 +279,4 @@ def volumes_from_entity_volumes_msg(msg):

if __name__ == "__main__":
import doctest

doctest.testmod()
Empty file added robot_skills/test/__init__.py
Empty file.
13 changes: 13 additions & 0 deletions robot_skills/test/test_doctest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from test_tools.doctest_unittest import _TestDocTests
import unittest


class DocTestsRobotSkills(_TestDocTests):
def __init__(self, method_name="test_doctests"):
super(DocTestsRobotSkills, self).__init__(module_name="robot_skills", method_name=method_name)


if __name__ == '__main__':
suite = unittest.TestSuite()
suite.addTest(DocTestsRobotSkills())
unittest.TextTestRunner(verbosity=2).run(suite)
13 changes: 13 additions & 0 deletions robot_skills/test/test_import.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import unittest


class TestImport(unittest.TestCase):
def test_import(self):
"""
If no exception is raised, this test will succeed
"""
import robot_skills


if __name__ == '__main__':
unittest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,5 @@ def __repr__(self):


if __name__ == "__main__":

import doctest

doctest.testmod()

0 comments on commit cc9514a

Please sign in to comment.