This directory contains the pytest-based test suite for solc-select.
The test suite is organized into two main categories:
- End-to-end tests that verify actual CLI behavior
- Real HTTP requests, filesystem operations, and binary execution
- Platform-specific validation
test_compiler_versions.py- Tests for different Solidity compiler versionstest_platform_specific.py- Platform-specific boundary teststest_upgrade.py- Tests for upgrade functionalitytest_network_isolation.py- Verifies offline execution after installationtest_version_verification.py- Version and checksum verification
- Fast, isolated tests with mocked dependencies
- Service layer business logic
- Repository matching algorithms
- Checksum verification and parallel downloads
- Platform detection and emulation handling
- Organized by layer:
services/- Service layer tests (VersionManager, ArtifactManager, etc.)infrastructure/- Infrastructure layer tests (FilesystemManager, HTTP client)models/- Domain model tests (VersionRange, SolcArtifact, etc.)
# Install with all development dependencies (testing + linting) uv pip install -e ".[dev]"# Run all tests (both unit and integration) uv run pytest tests/ # Run only unit tests (fast) uv run pytest tests/unit/ -v # Run only integration tests (slower, requires network) uv run pytest tests/integration/ -v# Unit tests uv run pytest tests/unit/services/test_version_manager.py uv run pytest tests/unit/services/test_artifact_manager.py # Integration tests uv run pytest tests/integration/test_compiler_versions.py uv run pytest tests/integration/test_platform_specific.py uv run pytest tests/integration/test_upgrade.py# Coverage for unit tests uv run pytest tests/unit/ --cov=solc_select --cov-report=term-missing # Coverage for all tests uv run pytest tests/ --cov=solc_select --cov-report=html# Only run tests for current platform pytest -m "not (linux or macos or windows)" # Run Linux-specific tests (only works on Linux) pytest -m linux # Run macOS-specific tests (only works on macOS) pytest -m macos # Run Windows-specific tests (only works on Windows) pytest -m windowspytest -n autoThe test suite uses different fixtures depending on the test type:
isolated_solc_data- Creates isolated solc-select data environment using VIRTUAL_ENVisolated_python_env- Creates completely isolated Python environment for install/uninstall teststest_contracts_dir- Path to test Solidity contracts intests/solidity_tests/- Helper functions:
run_command- Executes shell commands for tests usingisolated_solc_datarun_in_venv- Executes commands in isolated virtual environments
mock_session- Mock requests.Session for HTTP callsmock_filesystem- Mock FilesystemManagermock_platform- Mock Platform (linux-amd64 by default)mock_repository- Mock SolcRepository with common version settemp_artifacts_dir- Temporary artifacts directory for testingtemp_solc_select_dir- Temporary solc-select directory with isolated paths
| Test Module | Test Class | Description |
|---|---|---|
| test_compiler_versions.py | TestCompilerVersions | Compiler version tests |
| test_compiler_versions.py | TestVersionSwitching | Version switching functionality tests |
| test_platform_specific.py | TestPlatformSpecific | Platform boundary tests |
| test_upgrade.py | TestUpgrade | Upgrade preservation tests |
Test configuration is defined in pyproject.toml under [tool.pytest.ini_options], including:
- Custom markers for platform-specific tests (linux, macos, windows)
- Test discovery patterns
- Default options for verbose output and strict marker checking