Skip to content

Fix mock content initialization in test fixtures#190

Closed
metaodi wants to merge 1 commit into
claude/refactor-to-pythonic-stylefrom
fix-mock-content-initialization
Closed

Fix mock content initialization in test fixtures#190
metaodi wants to merge 1 commit into
claude/refactor-to-pythonic-stylefrom
fix-mock-content-initialization

Conversation

@metaodi
Copy link
Copy Markdown
Owner

@metaodi metaodi commented Feb 18, 2026

This commit addresses test failures caused by mock objects being passed to XML parsing functions. The issue occurred when test fixture files couldn't be found, leaving response_mock.content uninitialized as a Mock object instead of bytes/string.

Changes:

  1. Initialize response_mock.content to empty string when no fixture file is found, preventing TypeError in XML parsing
  2. Add fallback logic to handle fixture file naming mismatches between snake_case test method names and CamelCase fixture files
  3. Implement case-insensitive fixture file lookup for backward compatibility
  4. Fix black formatting issue in osmapi/OsmApi.py (add blank line after module docstring)
  5. Update test_Capabilities_deprecation_warning to explicitly specify fixture file

The fixture lookup now tries multiple strategies:

  • Exact filename match
  • Case-insensitive match
  • snake_case to CamelCase conversion (e.g., test_way_get.xml -> test_WayGet.xml)

This fixes the test_Capabilities_deprecation_warning test and many other tests that were failing due to fixture file naming mismatches after the snake_case refactoring.

🤖 Generated with Claude Code

This commit addresses test failures caused by mock objects being passed
to XML parsing functions. The issue occurred when test fixture files
couldn't be found, leaving response_mock.content uninitialized as a
Mock object instead of bytes/string.

Changes:
1. Initialize response_mock.content to empty string when no fixture
   file is found, preventing TypeError in XML parsing
2. Add fallback logic to handle fixture file naming mismatches between
   snake_case test method names and CamelCase fixture files
3. Implement case-insensitive fixture file lookup for backward
   compatibility
4. Fix black formatting issue in osmapi/OsmApi.py (add blank line
   after module docstring)
5. Update test_Capabilities_deprecation_warning to explicitly specify
   fixture file

The fixture lookup now tries multiple strategies:
- Exact filename match
- Case-insensitive match
- snake_case to CamelCase conversion (e.g., test_way_get.xml ->
  test_WayGet.xml)

This fixes the test_Capabilities_deprecation_warning test and many
other tests that were failing due to fixture file naming mismatches
after the snake_case refactoring.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@metaodi metaodi closed this Feb 18, 2026
@metaodi metaodi deleted the fix-mock-content-initialization branch February 18, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants