feat: add comprehensive unit tests for bittensor.core.threadpool module #3169
+293
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request: Add Comprehensive Unit Tests for ThreadPool Module
Bug
Missing test coverage for critical infrastructure component
bittensor/core/threadpool.py(10.5KB). The PriorityThreadPoolExecutor had no dedicated unit tests, leaving critical concurrent task execution infrastructure untested.Description of the Change
This PR adds a comprehensive test suite (
tests/unit_tests/test_threadpool.py) with 35 unit tests covering all aspects of the threadpool module:Test Coverage Added:
Core Functionality (9 tests)
Task Submission & Priority Management (5 tests)
Thread Pool Scaling & Lifecycle (2 tests)
Shutdown Behavior (3 tests)
Error Handling (2 tests)
Initializer Functions (2 tests)
Configuration & Environment (5 tests)
Worker Function Behavior (2 tests)
Edge Cases (5 tests)
Alternate Designs
Alternative approaches considered:
The chosen approach provides thorough unit-level testing while maintaining test independence and fast execution.
Possible Drawbacks
time.sleep()which may be flaky in extremely slow CI environmentsResults:
All tests pass successfully:
Test Categories Verified:
Contribution by Gittensor, learn more at https://gittensor.io/