Skip to content

Conversation

@dlevy-msft-sql
Copy link
Contributor

@dlevy-msft-sql dlevy-msft-sql commented Jan 22, 2026

Fixes #409

Summary

Removes dead code and improves code quality in tests/test_004_cursor.py by eliminating 28 duplicate test function definitions and fixing 53 bare except blocks.

Changes

Removed 28 duplicate test function definitions (~1,267 lines of dead code)

Python only runs the last definition when there are duplicate function names, so all earlier duplicates were dead code. This PR keeps the last (working) occurrence of each:

Function Duplicates Removed Notes
test_decimal_separator_* (4 functions) 3 each (12 total) All identical
test_lowercase_attribute 2 All identical
test_rowcount 1 Versions differed
test_columns_nonexistent 1 Version 1 was missing .fetchall()
test_all_numeric_types_with_nulls 1 Identical
test_lob_* (4 functions) 1 each Identical
test_zero_length_complex_types 1 Identical
test_guid_with_nulls 1 Identical
test_datetimeoffset_with_nulls 1 Identical
test_decimal_conversion_edge_cases 1 Identical
test_fixed_length_* (3 functions) 1 each Binary version differed

Fixed 53 bare except: blocks

  • 29 replaced with DROP TABLE IF EXISTS pattern (cleaner, no try/except needed)
  • 24 replaced with except Exception: for expected error handling

Results

  • File size: 15,021 to 13,754 lines (-8.4%)
  • All 423 tests pass

Fixes microsoft#409

- Removed 28 duplicate test function definitions (~1,267 lines of dead code)
  - Kept the LAST occurrence of each duplicate (what Python actually runs)
  - test_decimal_separator_* (4 functions × 3 duplicates each)
  - test_lowercase_attribute (2 duplicates)
  - test_rowcount (1 duplicate - versions differed)
  - test_columns_nonexistent (1 duplicate - versions differed)
  - test_all_numeric_types_with_nulls (1 duplicate)
  - test_lob_* (4 functions × 1 duplicate each)
  - test_zero_length_complex_types (1 duplicate)
  - test_guid_with_nulls (1 duplicate)
  - test_datetimeoffset_with_nulls (1 duplicate)
  - test_decimal_conversion_edge_cases (1 duplicate)
  - test_fixed_length_* (3 functions × 1 duplicate each, binary version differed)

- Fixed 53 bare \\�xcept:\\ blocks:
  - 29 replaced with \\DROP TABLE IF EXISTS\\ pattern (cleaner cleanup)
  - 24 replaced with \\�xcept Exception:\\ for expected error handling

File reduced from 15,021 to 13,754 lines (-8.4%)

All 423 tests pass.
Copilot AI review requested due to automatic review settings January 22, 2026 01:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dlevy-msft-sql dlevy-msft-sql added pr-size: small Minimal code update FIXED and removed FIXED labels Jan 22, 2026
@github-actions
Copy link

github-actions bot commented Jan 22, 2026

📊 Code Coverage Report

🔥 Diff Coverage

100%


🎯 Overall Coverage

76%


📈 Total Lines Covered: 5431 out of 7084
📁 Project: mssql-python


Diff Coverage

Diff: main...HEAD, staged and unstaged changes

No 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.pybind.ddbc_bindings.cpp: 69.4%
mssql_python.pybind.ddbc_bindings.h: 69.7%
mssql_python.pybind.connection.connection.cpp: 73.6%
mssql_python.ddbc_bindings.py: 79.6%
mssql_python.pybind.connection.connection_pool.cpp: 79.6%
mssql_python.connection.py: 84.1%
mssql_python.cursor.py: 84.7%

🔗 Quick Links

⚙️ Build Summary 📋 Coverage Details

View Azure DevOps Build

Browse Full Coverage Report

@dlevy-msft-sql dlevy-msft-sql changed the title fix: Remove duplicate test functions and bare except blocks FIX: Remove duplicate test functions and bare except blocks Jan 22, 2026
@dlevy-msft-sql dlevy-msft-sql changed the title FIX: Remove duplicate test functions and bare except blocks REFACTOR: Remove duplicate test functions and bare except blocks Jan 22, 2026
@dlevy-msft-sql dlevy-msft-sql changed the title REFACTOR: Remove duplicate test functions and bare except blocks FIX: Remove duplicate test functions and bare except blocks Jan 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-size: small Minimal code update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Code quality: Remove duplicate test functions and bare except blocks

1 participant