2121 _parse_tags ,
2222)
2323
24+
2425def test_find_config_cross_platform (tmpdir ):
2526 """Test _find_config works correctly across different platforms."""
2627 # Create a completely separate directory for isolated tests
2728 import tempfile
29+
2830 with tempfile .TemporaryDirectory () as isolated_root :
2931 # Setup test directory structure for positive tests
3032 config = tmpdir .join (".sagemaker-code-config" )
3133 config .write ('{"sagemakerProjectId": "proj-1234"}' )
32-
34+
3335 # Test 1: Direct parent directory
3436 working_dir = tmpdir .mkdir ("sub" )
3537 found_path = _find_config (working_dir )
3638 assert found_path == config
37-
39+
3840 # Test 2: Deeply nested directories
3941 nested_dir = tmpdir .mkdir ("deep" ).mkdir ("nested" ).mkdir ("path" )
4042 found_path = _find_config (nested_dir )
4143 assert found_path == config
42-
44+
4345 # Test 3: Start from root directory
4446 import os
47+
4548 root_dir = os .path .abspath (os .sep )
4649 found_path = _find_config (root_dir )
4750 assert found_path is None
48-
51+
4952 # Test 4: No config file in path - using truly isolated directory
5053 isolated_path = Path (isolated_root ) / "nested" / "path"
5154 isolated_path .mkdir (parents = True )
5255 found_path = _find_config (isolated_path )
5356 assert found_path is None
5457
58+
5559def test_find_config_path_separators (tmpdir ):
5660 """Test _find_config handles different path separator styles.
57-
61+
5862 Tests:
5963 1. Forward slashes
6064 2. Backslashes
@@ -64,20 +68,21 @@ def test_find_config_path_separators(tmpdir):
6468 config = tmpdir .join (".sagemaker-code-config" )
6569 config .write ('{"sagemakerProjectId": "proj-1234"}' )
6670 base_path = str (tmpdir )
67-
71+
6872 # Test different path separator styles
6973 paths = [
7074 os .path .join (base_path , "dir1" , "dir2" ), # OS native
71- "/" .join ([base_path , "dir1" , "dir2" ]), # Forward slashes
72- "\\ " .join ([base_path , "dir1" , "dir2" ]), # Backslashes
73- base_path + "/dir1\\ dir2" # Mixed
75+ "/" .join ([base_path , "dir1" , "dir2" ]), # Forward slashes
76+ "\\ " .join ([base_path , "dir1" , "dir2" ]), # Backslashes
77+ base_path + "/dir1\\ dir2" , # Mixed
7478 ]
75-
79+
7680 for path in paths :
7781 os .makedirs (path , exist_ok = True )
7882 found_path = _find_config (path )
7983 assert found_path == config
8084
85+
8186def test_find_config (tmpdir ):
8287 path = tmpdir .join (".sagemaker-code-config" )
8388 path .write ('{"sagemakerProjectId": "proj-1234"}' )
0 commit comments