@@ -29,20 +29,20 @@ def solc_select_path() -> Path:
2929def backup_current_version (solc_select_path : Path ) -> Generator [None , None , None ]:
3030 """
3131 Backup and restore the current solc version.
32-
32+
3333 This fixture ensures that each test starts with a clean state
3434 and doesn't affect the user's current solc configuration.
3535 """
3636 global_version_file = solc_select_path / "global-version"
3737 backup_file = None
38-
38+
3939 # Backup current version if it exists
4040 if global_version_file .exists ():
4141 backup_file = global_version_file .with_suffix (".backup" )
4242 shutil .copy2 (global_version_file , backup_file )
43-
43+
4444 yield
45-
45+
4646 # Restore original version
4747 if backup_file and backup_file .exists ():
4848 shutil .copy2 (backup_file , global_version_file )
@@ -56,27 +56,27 @@ def backup_current_version(solc_select_path: Path) -> Generator[None, None, None
5656def clean_artifacts (solc_select_path : Path ) -> Generator [None , None , None ]:
5757 """
5858 Clean up test artifacts after each test.
59-
59+
6060 This is used for tests that need complete isolation and
6161 should start with no installed versions.
6262 """
6363 artifacts_dir = solc_select_path / "artifacts"
6464 backup_dir = None
65-
65+
6666 # Backup existing artifacts if they exist
6767 if artifacts_dir .exists ():
6868 backup_dir = artifacts_dir .with_suffix (".backup" )
6969 if backup_dir .exists ():
7070 shutil .rmtree (backup_dir )
7171 shutil .copytree (artifacts_dir , backup_dir )
7272 shutil .rmtree (artifacts_dir )
73-
73+
7474 yield
75-
75+
7676 # Clean up test artifacts
7777 if artifacts_dir .exists ():
7878 shutil .rmtree (artifacts_dir )
79-
79+
8080 # Restore original artifacts if they existed
8181 if backup_dir and backup_dir .exists ():
8282 shutil .copytree (backup_dir , artifacts_dir )
@@ -87,35 +87,38 @@ def clean_artifacts(solc_select_path: Path) -> Generator[None, None, None]:
8787def run_command ():
8888 """
8989 Execute shell commands and return output.
90-
90+
9191 This fixture provides a conservative way to run commands,
9292 exactly as the bash tests did.
9393 """
94- def _run (cmd : str , check : bool = True , capture_stderr : bool = True ) -> subprocess .CompletedProcess :
94+
95+ def _run (
96+ cmd : str , check : bool = True , capture_stderr : bool = True
97+ ) -> subprocess .CompletedProcess :
9598 """
9699 Run a shell command and return the result.
97-
100+
98101 Args:
99102 cmd: Command to run
100103 check: Whether to raise on non-zero exit code
101104 capture_stderr: Whether to capture stderr
102-
105+
103106 Returns:
104107 CompletedProcess instance with stdout, stderr, and returncode
105108 """
106109 stderr_setting = subprocess .STDOUT if capture_stderr else subprocess .PIPE
107-
110+
108111 result = subprocess .run (
109112 cmd ,
110113 shell = True ,
111114 capture_output = False ,
112115 stdout = subprocess .PIPE ,
113116 stderr = stderr_setting ,
114117 text = True ,
115- check = check
118+ check = check ,
116119 )
117120 return result
118-
121+
119122 return _run
120123
121124
@@ -129,33 +132,23 @@ def test_contracts_dir() -> Path:
129132def ensure_solc_select_installed ():
130133 """
131134 Ensure solc-select is installed in development mode.
132-
135+
133136 This runs once per test session to ensure the current
134137 development version is being tested.
135138 """
136139 # Check if solc-select is available
137- result = subprocess .run (
138- ["solc-select" , "--help" ],
139- capture_output = True ,
140- text = True
141- )
142-
140+ result = subprocess .run (["solc-select" , "--help" ], capture_output = True , text = True )
141+
143142 if result .returncode != 0 :
144143 pytest .exit ("solc-select is not installed. Please run: pip install -e ." )
145144
146145
147146# Platform markers for conditional test execution
148147def pytest_configure (config ):
149148 """Register custom markers."""
150- config .addinivalue_line (
151- "markers" , "linux: mark test to run only on Linux"
152- )
153- config .addinivalue_line (
154- "markers" , "macos: mark test to run only on macOS"
155- )
156- config .addinivalue_line (
157- "markers" , "windows: mark test to run only on Windows"
158- )
149+ config .addinivalue_line ("markers" , "linux: mark test to run only on Linux" )
150+ config .addinivalue_line ("markers" , "macos: mark test to run only on macOS" )
151+ config .addinivalue_line ("markers" , "windows: mark test to run only on Windows" )
159152
160153
161154def pytest_runtest_setup (item ):
@@ -165,4 +158,4 @@ def pytest_runtest_setup(item):
165158 if "macos" in item .keywords and sys .platform != "darwin" :
166159 pytest .skip ("Test requires macOS" )
167160 if "windows" in item .keywords and sys .platform != "win32" :
168- pytest .skip ("Test requires Windows" )
161+ pytest .skip ("Test requires Windows" )
0 commit comments