FIX: Optimizing test run time without impacting coverage#380
Merged
gargsaumya merged 4 commits intomainfrom Dec 18, 2025
Merged
FIX: Optimizing test run time without impacting coverage#380gargsaumya merged 4 commits intomainfrom
gargsaumya merged 4 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request optimizes test execution time in two test files without compromising test coverage. The optimization strategy includes reducing iteration counts, lowering subprocess timeouts, and consolidating repetitive tests into parameterized test cases using pytest.mark.parametrize.
Key Changes:
- Reduced subprocess timeout values from 30 seconds to 3-5 seconds across multiple tests
- Consolidated 8 separate
_cleanup_connections()test methods into a single parameterized test with 8 scenarios - Parameterized multiple similar Unicode/UTF-8 test cases for better maintainability
- Reduced iteration counts in stress tests (e.g., 10→5, 5→2 GC cycles) and string length tests (e.g., 10000→1000 characters)
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/test_013_SqlHandle_free_shutdown.py | Added pytest import; reduced iteration counts and subprocess timeouts; consolidated 8 _cleanup_connections() tests into a single parameterized test; updated assertions to match new iteration counts |
| tests/test_014_ddbc_bindings_coverage.py | Refactored multiple test methods into parameterized tests using @pytest.mark.parametrize; reduced long string test sizes for faster execution; consolidated UTF-8 encoding/decoding tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
📊 Code Coverage Report
Diff CoverageDiff: main...HEAD, staged and unstaged changesNo lines with coverage information in this diff. 📋 Files Needing Attention📉 Files with overall lowest coverage (click to expand)mssql_python.pybind.logger_bridge.hpp: 58.8%
mssql_python.pybind.logger_bridge.cpp: 59.2%
mssql_python.row.py: 66.2%
mssql_python.helpers.py: 67.5%
mssql_python.pybind.ddbc_bindings.cpp: 69.3%
mssql_python.pybind.connection.connection.cpp: 73.6%
mssql_python.ddbc_bindings.py: 79.6%
mssql_python.connection.py: 83.9%
mssql_python.cursor.py: 84.4%
mssql_python.__init__.py: 84.9%🔗 Quick Links
|
sumitmsft
approved these changes
Dec 18, 2025
gargsaumya
approved these changes
Dec 18, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Work Item / Issue Reference
Summary
This pull request refactors and optimizes the
tests/test_013_SqlHandle_free_shutdown.pytest suite to improve test execution speed and maintainability. The main changes include reducing iteration counts and timeouts for faster test runs, and consolidating several similar tests into a single parameterized test usingpytest.mark.parametrize. This makes the tests more efficient and easier to manage.Test performance improvements:
Test suite maintainability:
_cleanup_connections()into a single parameterized test usingpytest.mark.parametrize, reducing code duplication and improving readability. The scenarios now covered are: normal flow, already closed connections, missing_closedattribute, exception handling, multiple connections, and WeakSet behavior. [1] [2] [3] [4] [5] [6]Test framework modernization:
pytestimport and usage to support parameterized testing.Test output and assertion updates:
These changes make the test suite faster, more robust, and easier to extend in the future.