Extract common testcase class
This commit is contained in:
		
							parent
							
								
									cc3c142f9f
								
							
						
					
					
						commit
						05d60cb57a
					
				
					 9 changed files with 194 additions and 223 deletions
				
			
		| 
						 | 
				
			
			@ -14,40 +14,24 @@
 | 
			
		|||
 | 
			
		||||
import unittest
 | 
			
		||||
 | 
			
		||||
from tracetools_test.utils import (
 | 
			
		||||
    cleanup_trace,
 | 
			
		||||
    get_trace_event_names,
 | 
			
		||||
    run_and_trace,
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
BASE_PATH = '/tmp'
 | 
			
		||||
PKG = 'tracetools_test'
 | 
			
		||||
node_creation_events = [
 | 
			
		||||
    'ros2:rcl_init',
 | 
			
		||||
    'ros2:rcl_node_init',
 | 
			
		||||
]
 | 
			
		||||
from tracetools_test.case import TraceTestCase
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class TestNode(unittest.TestCase):
 | 
			
		||||
class TestNode(TraceTestCase):
 | 
			
		||||
 | 
			
		||||
    def __init__(self, *args) -> None:
 | 
			
		||||
        super().__init__(
 | 
			
		||||
            *args,
 | 
			
		||||
            session_name_prefix='session-test-node-creation',
 | 
			
		||||
            events_ros=[
 | 
			
		||||
                'ros2:rcl_init',
 | 
			
		||||
                'ros2:rcl_node_init',
 | 
			
		||||
            ],
 | 
			
		||||
            nodes=['test_publisher']
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def test_creation(self):
 | 
			
		||||
        session_name_prefix = 'session-test-node-creation'
 | 
			
		||||
        test_node = ['test_publisher']
 | 
			
		||||
 | 
			
		||||
        exit_code, full_path = run_and_trace(
 | 
			
		||||
            BASE_PATH,
 | 
			
		||||
            session_name_prefix,
 | 
			
		||||
            node_creation_events,
 | 
			
		||||
            None,
 | 
			
		||||
            PKG,
 | 
			
		||||
            test_node)
 | 
			
		||||
        self.assertEqual(exit_code, 0)
 | 
			
		||||
 | 
			
		||||
        trace_events = get_trace_event_names(full_path)
 | 
			
		||||
        print(f'trace_events: {trace_events}')
 | 
			
		||||
        self.assertSetEqual(set(node_creation_events), trace_events)
 | 
			
		||||
 | 
			
		||||
        cleanup_trace(full_path)
 | 
			
		||||
        pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if __name__ == '__main__':
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue