Skip to content

Commit 4af423b

Browse files
committed
fix: resolve pylint warnings in test files
- Add explicit check=False parameter to subprocess.run calls - Mark unused fixture arguments as intentionally unused with _ assignment - Move module imports to top level instead of inside functions - Disable too-few-public-methods warning for test classes - Fix all W0613 (unused-argument) warnings - Fix all C0415 (import-outside-toplevel) warnings - Fix all W1510 (subprocess-run-check) warnings
1 parent 4c07aca commit 4af423b

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def ensure_solc_select_installed():
137137
development version is being tested.
138138
"""
139139
# Check if solc-select is available
140-
result = subprocess.run(["solc-select", "--help"], capture_output=True, text=True)
140+
result = subprocess.run(["solc-select", "--help"], capture_output=True, text=True, check=False)
141141

142142
if result.returncode != 0:
143143
pytest.exit("solc-select is not installed. Please run: pip install -e .")

tests/test_compiler_versions.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
exactly mirroring the behavior of the original test_solc.sh script.
66
"""
77

8+
import os
9+
import shutil
10+
811
import 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

tests/test_platform_specific.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@
1111
import pytest
1212

1313

14-
class TestLinuxSpecific:
14+
class TestLinuxSpecific: # pylint: disable=too-few-public-methods
1515
"""Linux-specific version boundary tests."""
1616

1717
@pytest.mark.linux
1818
def test_linux_version_boundaries(self, run_command, backup_current_version):
1919
"""Test Linux version boundaries and constraints."""
20+
_ = backup_current_version # Fixture ensures clean state
2021
# Install all versions (as original script does)
2122
run_command("solc-select install all", check=False)
2223

@@ -55,12 +56,13 @@ def test_linux_version_boundaries(self, run_command, backup_current_version):
5556
), f"Did not fail for version too high. Output: {result.stdout}"
5657

5758

58-
class TestMacOSSpecific:
59+
class TestMacOSSpecific: # pylint: disable=too-few-public-methods
5960
"""macOS-specific version boundary tests."""
6061

6162
@pytest.mark.macos
6263
def test_macos_version_boundaries(self, run_command, backup_current_version):
6364
"""Test macOS version boundaries and constraints."""
65+
_ = backup_current_version # Fixture ensures clean state
6466
# Install all versions (as original script does)
6567
run_command("solc-select install all", check=False)
6668

@@ -99,12 +101,13 @@ def test_macos_version_boundaries(self, run_command, backup_current_version):
99101
), f"Did not fail for version too high. Output: {result.stdout}"
100102

101103

102-
class TestWindowsSpecific:
104+
class TestWindowsSpecific: # pylint: disable=too-few-public-methods
103105
"""Windows-specific version boundary tests."""
104106

105107
@pytest.mark.windows
106108
def test_windows_version_boundaries(self, run_command, backup_current_version):
107109
"""Test Windows version boundaries and constraints."""
110+
_ = backup_current_version # Fixture ensures clean state
108111
# Install all versions (as original script does)
109112
run_command("solc-select install all", check=False)
110113

tests/test_upgrade.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
import pytest
1111

1212

13-
class TestUpgrade:
13+
class TestUpgrade: # pylint: disable=too-few-public-methods
1414
"""Test solc-select upgrade behavior."""
1515

1616
@pytest.mark.slow # This test reinstalls packages, so it's slow
17-
def test_upgrade_preserves_versions(self, run_command, tmp_path):
17+
def test_upgrade_preserves_versions(self, run_command, tmp_path): # pylint: disable=unused-argument
1818
"""
1919
Test that upgrading solc-select preserves installed versions.
2020

0 commit comments

Comments
 (0)