def test_get_time(self): fn = '/tmp/test_get_time.bag' with rosbag.Bag(fn, mode='w') as bag: for i in xrange(100): bag.write("/test_bag", Int32(data=i), t=genpy.Time.from_sec(i)) with rosbag.Bag(fn) as bag: start_stamp = bag.get_start_time() end_stamp = bag.get_end_time() self.assertEquals(start_stamp, 0.0) self.assertEquals(end_stamp, 99.0)