|
13 | 13 | # language governing permissions and limitations under the License.
|
14 | 14 | from __future__ import absolute_import
|
15 | 15 | import os
|
| 16 | +import platform |
16 | 17 | from pathlib import Path
|
17 | 18 | from sagemaker._studio import (
|
18 | 19 | _append_project_tags,
|
@@ -69,20 +70,22 @@ def test_find_config_path_separators(tmpdir):
|
69 | 70 | config.write('{"sagemakerProjectId": "proj-1234"}')
|
70 | 71 | base_path = str(tmpdir)
|
71 | 72 |
|
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 | + ]) |
79 | 83 |
|
80 | 84 | for path in paths:
|
81 | 85 | os.makedirs(path, exist_ok=True)
|
82 | 86 | found_path = _find_config(path)
|
83 | 87 | assert found_path == config
|
84 | 88 |
|
85 |
| - |
86 | 89 | def test_find_config(tmpdir):
|
87 | 90 | path = tmpdir.join(".sagemaker-code-config")
|
88 | 91 | path.write('{"sagemakerProjectId": "proj-1234"}')
|
|
0 commit comments