File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -940,9 +940,10 @@ def split_path_mapping(volume_path):
940940 path. Using splitdrive so windows absolute paths won't cause issues with
941941 splitting on ':'.
942942 """
943- # splitdrive has limitations when it comes to relative paths, so when it's
944- # relative, handle special case to set the drive to ''
945- if volume_path .startswith ('.' ) or volume_path .startswith ('~' ):
943+ # splitdrive is very naive, so handle special cases where we can be sure
944+ # the first character is not a drive.
945+ if (volume_path .startswith ('.' ) or volume_path .startswith ('~' ) or
946+ volume_path .startswith ('/' )):
946947 drive , volume_config = '' , volume_path
947948 else :
948949 drive , volume_config = ntpath .splitdrive (volume_path )
Original file line number Diff line number Diff line change @@ -2682,6 +2682,13 @@ def test_split_path_mapping_with_windows_path_in_container(self):
26822682 mapping = config .split_path_mapping ('{0}:{1}' .format (host_path , container_path ))
26832683 assert mapping == expected_mapping
26842684
2685+ def test_split_path_mapping_with_root_mount (self ):
2686+ host_path = '/'
2687+ container_path = '/var/hostroot'
2688+ expected_mapping = (container_path , host_path )
2689+ mapping = config .split_path_mapping ('{0}:{1}' .format (host_path , container_path ))
2690+ assert mapping == expected_mapping
2691+
26852692
26862693@pytest .mark .xfail (IS_WINDOWS_PLATFORM , reason = 'paths use slash' )
26872694class BuildPathTest (unittest .TestCase ):
You can’t perform that action at this time.
0 commit comments