Skip to content

Latest commit

 

History

History
70 lines (58 loc) · 3.11 KB

File metadata and controls

70 lines (58 loc) · 3.11 KB

Pull Request: Improve test coverage, fix bugs, add closed property, and analyze issues

Summary

This PR improves the stream2py codebase by enhancing test coverage, fixing several bugs, implementing the closed property feature, and providing comprehensive analysis of all open issues.

Changes Made

Bug Fixes

  • Python 3.11+ compatibility: Fixed test_util.py to handle both TypeError and AttributeError for context manager protocol violations
  • QuickSourceReader bug: Added missing open_instance attribute that was referenced in info property but never set
  • SimpleSourceReader bug: Fixed to return None instead of raising StopIteration when data is exhausted
  • Documentation: Fixed syntax error in __init__.py docstring (missing colon in property definition)

Features

  • Closed property (#6): Implemented closed property for SourceReader similar to io.IOBase.closed
    • Added _closed attribute to track open/close state
    • Updated __enter__ and __exit__ to manage the flag
    • Updated QuickSourceReader to properly set closed state
    • Added docstring examples demonstrating usage

Tests

  • BufferReader blocking tests: Added comprehensive tests for the blocking parameter
    • Tests for blocking=True and blocking=False behavior
    • Tests for blocking read when buffer stops
  • QuickSourceReader tests: Added 6 new tests covering:
    • Basic functionality
    • Context manager usage
    • Info property
    • Key method
    • Iteration behavior
    • Custom is_valid_data filtering

Documentation

  • ISSUE_ANALYSIS.md: Created comprehensive analysis of all 17 open issues
    • Categorized by status: already resolved, simple fixes, medium effort, complex/ongoing, external
    • Identified dependencies and relationships between issues
    • Provided resolution recommendations for each
    • Documented that #20 is already resolved and #8 is partially resolved

Test Results

  • Before: 11 tests (1 failing)
  • After: 19 tests (all passing)
  • Coverage: +8 new tests added

Issues Addressed

  • Resolves #6 (closed property for SourceReader)
  • Documents #20 as already resolved (blocking parameter exists in BufferReader.read())
  • Documents #8 as partially resolved (blocking exists, timeout could be added)

Files Changed

  • stream2py/__init__.py - Fixed docstring syntax error
  • stream2py/source_reader.py - Added closed property, fixed QuickSourceReader bug
  • stream2py/tests/test_util.py - Fixed Python 3.11+ compatibility
  • stream2py/tests/utils_for_testing.py - Fixed SimpleSourceReader StopIteration handling
  • stream2py/tests/test_buffer_reader_blocking.py - New test file for blocking parameter
  • stream2py/tests/test_quick_source_reader.py - New test file for QuickSourceReader
  • ISSUE_ANALYSIS.md - New comprehensive issue analysis document

Breaking Changes

None - all changes are backward compatible.

Checklist

  • All tests passing (19/19)
  • Documentation updated
  • Backward compatible
  • Issue analysis completed
  • Code formatted

Next Steps

See ISSUE_ANALYSIS.md for recommended next steps and prioritization of remaining issues.