コード例 #1
0
def test_launch_description_source_methods():
    """Test the methods of the LaunchDescriptionSource class."""
    class MockLaunchContext:

        def perform_substitution(self, substitution):
            return substitution.perform(None)

    lds = LaunchDescriptionSource()
    with pytest.raises(RuntimeError):
        lds.get_launch_description(MockLaunchContext())

    ld = LaunchDescription()
    lds = LaunchDescriptionSource(ld)
    assert lds.get_launch_description(MockLaunchContext()) == ld

    ld = LaunchDescription()
    lds = LaunchDescriptionSource(ld, 'location')
    assert lds.get_launch_description(MockLaunchContext()) == ld
    assert lds.location == 'location'

    ld = LaunchDescription()
    lds = LaunchDescriptionSource(ld, 'location', 'method description')
    assert lds.get_launch_description(MockLaunchContext()) == ld
    assert lds.location == 'location'
    assert lds.method == 'method description'
コード例 #2
0
def test_launch_description_source_methods():
    """Test the methods of the LaunchDescriptionSource class."""
    class MockLaunchContext:
        ...

    lds = LaunchDescriptionSource()
    with pytest.raises(RuntimeError):
        lds.get_launch_description(MockLaunchContext())

    ld = LaunchDescription()
    lds = LaunchDescriptionSource(ld)
    assert lds.get_launch_description(MockLaunchContext()) == ld

    ld = LaunchDescription()
    lds = LaunchDescriptionSource(ld, 'location')
    assert lds.get_launch_description(MockLaunchContext()) == ld
    assert lds.location == 'location'

    ld = LaunchDescription()
    lds = LaunchDescriptionSource(ld, 'location', 'method description')
    assert lds.get_launch_description(MockLaunchContext()) == ld
    assert lds.location == 'location'
    assert lds.method == 'method description'