55exactly mirroring the behavior of the original test_solc.sh script.
66"""
77
8+ import os
9+ import shutil
10+
811import pytest
912
1013
@@ -20,6 +23,7 @@ def install_required_versions(self, run_command):
2023
2124 def test_solc_045 (self , run_command , test_contracts_dir , backup_current_version ):
2225 """Test Solidity 0.4.5 compilation behavior."""
26+ _ = backup_current_version # Fixture ensures clean state
2327 # Switch to 0.4.5
2428 result = run_command ("solc-select use 0.4.5" , check = False )
2529 assert result .returncode == 0 , f"Failed to switch to 0.4.5: { result .stdout } "
@@ -37,6 +41,7 @@ def test_solc_045(self, run_command, test_contracts_dir, backup_current_version)
3741
3842 def test_solc_050 (self , run_command , test_contracts_dir , backup_current_version ):
3943 """Test Solidity 0.5.0 compilation behavior."""
44+ _ = backup_current_version # Fixture ensures clean state
4045 # Switch to 0.5.0
4146 result = run_command ("solc-select use 0.5.0" , check = False )
4247 assert result .returncode == 0 , f"Failed to switch to 0.5.0: { result .stdout } "
@@ -55,6 +60,7 @@ def test_solc_050(self, run_command, test_contracts_dir, backup_current_version)
5560
5661 def test_solc_060 (self , run_command , test_contracts_dir , backup_current_version ):
5762 """Test Solidity 0.6.0 compilation behavior."""
63+ _ = backup_current_version # Fixture ensures clean state
5864 # Switch to 0.6.0
5965 result = run_command ("solc-select use 0.6.0" , check = False )
6066 assert result .returncode == 0 , f"Failed to switch to 0.6.0: { result .stdout } "
@@ -69,6 +75,7 @@ def test_solc_060(self, run_command, test_contracts_dir, backup_current_version)
6975
7076 def test_solc_070 (self , run_command , test_contracts_dir , backup_current_version ):
7177 """Test Solidity 0.7.0 compilation behavior."""
78+ _ = backup_current_version # Fixture ensures clean state
7279 # Switch to 0.7.0
7380 result = run_command ("solc-select use 0.7.0" , check = False )
7481 assert result .returncode == 0 , f"Failed to switch to 0.7.0: { result .stdout } "
@@ -86,6 +93,7 @@ def test_solc_070(self, run_command, test_contracts_dir, backup_current_version)
8693
8794 def test_solc_080 (self , run_command , test_contracts_dir , backup_current_version ):
8895 """Test Solidity 0.8.0 compilation behavior."""
96+ _ = backup_current_version # Fixture ensures clean state
8997 # Switch to 0.8.0
9098 result = run_command ("solc-select use 0.8.0" , check = False )
9199 assert result .returncode == 0 , f"Failed to switch to 0.8.0: { result .stdout } "
@@ -115,12 +123,11 @@ class TestVersionSwitching:
115123
116124 def test_always_install_flag (self , run_command , solc_select_path , backup_current_version ):
117125 """Test --always-install flag functionality."""
126+ _ = backup_current_version # Fixture ensures clean state
118127 # Safely remove 0.8.9 if it exists
119128 artifacts_path = solc_select_path / "artifacts"
120129
121130 # Validate path to ensure we're in the right place
122- import os
123-
124131 path_parts = str (artifacts_path ).replace (os .sep , "/" ).split ("/" )
125132 if len (path_parts ) < 2 or path_parts [- 2 :] != [".solc-select" , "artifacts" ]:
126133 pytest .fail (f"Unsafe artifacts path: { artifacts_path } " )
@@ -135,8 +142,6 @@ def test_always_install_flag(self, run_command, solc_select_path, backup_current
135142 file_path .unlink ()
136143 elif file_path .is_dir ():
137144 # On macOS, solc binaries are directories
138- import shutil
139-
140145 shutil .rmtree (file_path )
141146 except (PermissionError , OSError ):
142147 # If we can't delete, that's okay - test will still work
@@ -151,11 +156,11 @@ def test_always_install_flag(self, run_command, solc_select_path, backup_current
151156
152157 def test_use_without_install (self , run_command , solc_select_path , backup_current_version ):
153158 """Test that 'use' fails when version is not installed."""
159+ _ = backup_current_version # Fixture ensures clean state
154160 # Safely remove 0.8.1 if it exists
155161 artifacts_path = solc_select_path / "artifacts"
156162
157163 # Validate path to ensure we're in the right place
158- import os
159164
160165 path_parts = str (artifacts_path ).replace (os .sep , "/" ).split ("/" )
161166 if len (path_parts ) < 2 or path_parts [- 2 :] != [".solc-select" , "artifacts" ]:
@@ -171,8 +176,6 @@ def test_use_without_install(self, run_command, solc_select_path, backup_current
171176 file_path .unlink ()
172177 elif file_path .is_dir ():
173178 # On macOS, solc binaries are directories
174- import shutil
175-
176179 shutil .rmtree (file_path )
177180 except (PermissionError , OSError ):
178181 # If we can't delete, that's okay - test will still work
0 commit comments