Skip to content

Commit 9079baa

Browse files
committed
Fix testcase with \\ when running on non-windows machines
1 parent ebaf507 commit 9079baa

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

tests/unit/sagemaker/test_studio.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# language governing permissions and limitations under the License.
1414
from __future__ import absolute_import
1515
import os
16+
import platform
1617
from pathlib import Path
1718
from sagemaker._studio import (
1819
_append_project_tags,
@@ -69,20 +70,22 @@ def test_find_config_path_separators(tmpdir):
6970
config.write('{"sagemakerProjectId": "proj-1234"}')
7071
base_path = str(tmpdir)
7172

72-
# Test different path separator styles
73-
paths = [
74-
os.path.join(base_path, "dir1", "dir2"), # OS native
75-
"/".join([base_path, "dir1", "dir2"]), # Forward slashes
76-
"\\".join([base_path, "dir1", "dir2"]), # Backslashes
77-
base_path + "/dir1\\dir2", # Mixed
78-
]
73+
# Always include the OS native path and forward slashes (which are equivalent on all OS)
74+
paths = [os.path.join(base_path, "dir1", "dir2"),
75+
"/".join([base_path, "dir1", "dir2"])]
76+
77+
# Only on Windows add the backslashes and mixed separator test cases.
78+
if os.name == "nt":
79+
paths.extend([
80+
"\\".join([base_path, "dir1", "dir2"]),
81+
base_path + "/dir1\\dir2",
82+
])
7983

8084
for path in paths:
8185
os.makedirs(path, exist_ok=True)
8286
found_path = _find_config(path)
8387
assert found_path == config
8488

85-
8689
def test_find_config(tmpdir):
8790
path = tmpdir.join(".sagemaker-code-config")
8891
path.write('{"sagemakerProjectId": "proj-1234"}')

0 commit comments

Comments
 (0)