File tree Expand file tree Collapse file tree 4 files changed +23
-7
lines changed
test/launch/substitutions Expand file tree Collapse file tree 4 files changed +23
-7
lines changed Original file line number Diff line number Diff line change 2121from typing import Tuple
2222from typing import Type
2323
24-
24+ from . path_join_substitution import PathSubstitution
2525from ..frontend .expose import expose_substitution
2626from ..launch_context import LaunchContext
2727from ..logging import launch_config as launch_logging_config
2828from ..some_substitutions_type import SomeSubstitutionsType
29- from ..substitution import Substitution
3029
3130
3231@expose_substitution ('launch_log_dir' )
3332@expose_substitution ('log_dir' )
34- class LaunchLogDir (Substitution ):
33+ class LaunchLogDir (PathSubstitution ):
3534 """Substitution that returns the absolute path to the current launch log directory."""
3635
3736 def __init__ (self ) -> None :
3837 """Create a LaunchLogDir substitution."""
39- super ().__init__ ()
38+ super ().__init__ (self )
4039
4140 @classmethod
4241 def parse (cls , data : Sequence [SomeSubstitutionsType ]
Original file line number Diff line number Diff line change 2222from typing import Type
2323
2424
25+ from .path_join_substitution import PathSubstitution
2526from .substitution_failure import SubstitutionFailure
2627from ..frontend .expose import expose_substitution
2728from ..launch_context import LaunchContext
2829from ..some_substitutions_type import SomeSubstitutionsType
29- from ..substitution import Substitution
3030
3131
3232@expose_substitution ('dirname' )
33- class ThisLaunchFileDir (Substitution ):
33+ class ThisLaunchFileDir (PathSubstitution ):
3434 """Substitution that returns the absolute path to the current launch file."""
3535
3636 def __init__ (self ) -> None :
3737 """Create a ThisLaunchFileDir substitution."""
38- super ().__init__ ()
38+ super ().__init__ (self )
3939
4040 @classmethod
4141 def parse (cls , data : Sequence [SomeSubstitutionsType ]
Original file line number Diff line number Diff line change @@ -32,6 +32,14 @@ def test_launch_log_dir_methods():
3232 assert lld .perform (lc )
3333
3434
35+ def test_launch_log_dir_path ():
36+ test_dir = LaunchLogDir () / 'subdir'
37+ lc = LaunchContext ()
38+ result = test_dir .perform (lc )
39+ assert result
40+ assert result .endswith ('subdir' )
41+
42+
3543def test_launch_log_dir_frontend ():
3644 """Test launch_log_dir/log_dir frontend substitutions."""
3745 for sub in ('launch_log_dir' , 'log_dir' ):
Original file line number Diff line number Diff line change 1414
1515"""Tests for the ThisLaunchFileDir substitution class."""
1616
17+ import os
18+
1719from launch import LaunchContext
1820from launch .substitutions import SubstitutionFailure
1921from launch .substitutions import ThisLaunchFileDir
@@ -35,3 +37,10 @@ def test_this_launch_file_path_methods():
3537 tlfp .perform (lc )
3638 lc .extend_locals ({'current_launch_file_directory' : 'foo' })
3739 assert tlfp .perform (lc ) == 'foo'
40+
41+
42+ def test_this_launch_file_dir_pathing ():
43+ test_file = ThisLaunchFileDir () / 'some_launch.xml'
44+ lc = LaunchContext ()
45+ lc .extend_locals ({'current_launch_file_directory' : 'foo' })
46+ assert test_file .perform (lc ) == os .path .join ('foo' , 'some_launch.xml' )
You can’t perform that action at this time.
0 commit comments