test_bag_to_console.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 """
4 Test: grep input bags to console output.
5 
6 ------------------------------------------------------------------------------
7 This file is part of grepros - grep for ROS bag files and live topics.
8 Released under the BSD License.
9 
10 @author Erki Suurjaak
11 @created 22.12.2021
12 @modified 25.12.2021
13 ------------------------------------------------------------------------------
14 """
15 import logging
16 import os
17 import sys
18 
19 sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
20 from test import testbase
21 
22 logger = logging.getLogger()
23 
24 
26  """Tests grepping from input bags and printing matches to console."""
27 
28 
29  NAME = os.path.splitext(os.path.basename(__file__))[0]
30 
31 
32  OUTPUT_LABEL = "console"
33 
34  def setUp(self):
35  """Collects bags in data directory, assembles command."""
36  super().setUp()
37  self._cmd = list(self.CMD_BASE)
38 
39  def test_grepros(self):
40  """Runs grepros on bags in data directory, verifies console output."""
41  self.verify_bags()
42  fulltext = self.run_command()
43  self.assertTrue(fulltext, "Command did not print to console.")
44 
45  for bag in self._bags:
46  self.assertIn(os.path.basename(bag), fulltext, "Expected bag not in output.")
47  super().verify_topics(fulltext, fulltext)
48 
49 
50 if "__main__" == __name__:
51  TestBagInputConsoleOutput.run_rostest()
test.test_bag_to_console.TestBagInputConsoleOutput.setUp
def setUp(self)
Definition: test_bag_to_console.py:34
test.test_bag_to_console.TestBagInputConsoleOutput
Definition: test_bag_to_console.py:25
test.testbase.TestBase
Definition: testbase.py:46
test.test_bag_to_console.TestBagInputConsoleOutput.test_grepros
def test_grepros(self)
Definition: test_bag_to_console.py:39
test.testbase.TestBase.CMD_BASE
list CMD_BASE
Base command for running grepros.
Definition: testbase.py:71
test.testbase.TestBase.verify_topics
def verify_topics(self, topics, messages=None)
Definition: testbase.py:176
test.test_bag_to_console.TestBagInputConsoleOutput._cmd
_cmd
Definition: test_bag_to_console.py:37
test.testbase.TestBase._bags
_bags
Definition: testbase.py:94
test.testbase.TestBase.verify_bags
def verify_bags(self)
Definition: testbase.py:169
test.testbase.TestBase.run_command
def run_command(self, communicate=True)
Definition: testbase.py:154


grepros
Author(s): Erki Suurjaak
autogenerated on Sat Jan 6 2024 03:11:29