@@ -60,9 +60,9 @@ def test_system_finder_with_global_search():
6060 # Create a SystemFinder with global_search=True
6161 finder = SystemFinder (global_search = True )
6262
63- # Check that the paths from PATH were added
64- assert Path ( "/ usr/bin") in finder .paths
65- assert Path ( "/ usr/local/bin") in finder .paths
63+ # Check that the paths from PATH were added using path normalization
64+ assert any ( " usr/bin" in p . as_posix () for p in finder .paths )
65+ assert any ( " usr/local/bin" in p . as_posix () for p in finder .paths )
6666
6767
6868def test_system_finder_with_system ():
@@ -77,8 +77,8 @@ def test_system_finder_with_system():
7777 # Create a SystemFinder with system=True
7878 finder = SystemFinder (system = True )
7979
80- # Check that the system Python path was added
81- assert Path ( "/ usr/bin") in finder .paths
80+ # Check that the system Python path was added using path normalization
81+ assert any ( " usr/bin" in p . as_posix () for p in finder .paths )
8282
8383
8484def test_system_finder_with_virtual_env ():
@@ -95,10 +95,11 @@ def test_system_finder_with_virtual_env():
9595 finder = SystemFinder (global_search = False , system = False )
9696
9797 # Check that the virtual environment path was added
98- venv_path = Path (
99- "/path/to/venv/Scripts" if os .name == "nt" else "/path/to/venv/bin"
98+ bin_dir = "Scripts" if os .name == "nt" else "bin"
99+ # Use path normalization for cross-platform compatibility
100+ assert any (
101+ f"path/to/venv/{ bin_dir } " in p .as_posix () for p in finder .paths
100102 )
101- assert venv_path in finder .paths
102103
103104
104105def test_system_finder_with_custom_paths ():
@@ -117,10 +118,10 @@ def test_system_finder_with_custom_paths():
117118 # Create a SystemFinder with custom paths
118119 finder = SystemFinder (paths = custom_paths )
119120
120- # Check that the custom paths were added
121- assert Path ( "/ custom/path1") in finder .paths
122- assert Path ( "/ custom/path2") in finder .paths
123- assert Path ( "/ custom/path3") in finder .paths
121+ # Check that the custom paths were added using path normalization
122+ assert any ( " custom/path1" in p . as_posix () for p in finder .paths )
123+ assert any ( " custom/path2" in p . as_posix () for p in finder .paths )
124+ assert any ( " custom/path3" in p . as_posix () for p in finder .paths )
124125
125126
126127def test_system_finder_filters_non_existent_paths ():
@@ -141,11 +142,11 @@ def test_system_finder_filters_non_existent_paths():
141142 # Set up the mock to return True for existing paths and False for non-existent path
142143 def side_effect (path ):
143144 path_str = str (path )
144- if "/ existing/path1" in path_str :
145+ if "existing/path1" in path_str . replace ( " \\ " , "/" ) :
145146 return True
146- elif "/ non-existent/path" in path_str :
147+ elif "non-existent/path" in path_str . replace ( " \\ " , "/" ) :
147148 return False
148- elif "/ existing/path2" in path_str :
149+ elif "existing/path2" in path_str . replace ( " \\ " , "/" ) :
149150 return True
150151 return False
151152
@@ -155,9 +156,15 @@ def side_effect(path):
155156 finder = SystemFinder (paths = paths , global_search = False , system = False )
156157
157158 # Check that only the existing paths were added
158- assert any (str (p ).endswith ("/existing/path1" ) for p in finder .paths )
159- assert not any (str (p ).endswith ("/non-existent/path" ) for p in finder .paths )
160- assert any (str (p ).endswith ("/existing/path2" ) for p in finder .paths )
159+ assert any (
160+ "existing/path1" in str (p ).replace ("\\ " , "/" ) for p in finder .paths
161+ )
162+ assert not any (
163+ "non-existent/path" in str (p ).replace ("\\ " , "/" ) for p in finder .paths
164+ )
165+ assert any (
166+ "existing/path2" in str (p ).replace ("\\ " , "/" ) for p in finder .paths
167+ )
161168
162169
163170def test_system_finder_inherits_from_path_finder ():
0 commit comments