Skip to content

✨ Quality: Missing tests for settings cascade and override logic#2287

Merged
soxoj merged 1 commit intosoxoj:mainfrom
tang-vu:contribai/improve/quality/missing-tests-for-settings-cascade-and-o
Mar 21, 2026
Merged

✨ Quality: Missing tests for settings cascade and override logic#2287
soxoj merged 1 commit intosoxoj:mainfrom
tang-vu:contribai/improve/quality/missing-tests-for-settings-cascade-and-o

Conversation

@tang-vu
Copy link
Copy Markdown
Contributor

@tang-vu tang-vu commented Mar 20, 2026

Closes #2286

✨ Code Quality

Problem

The Settings.load() method iterates through multiple configuration file paths and updates the internal __dict__, intending to override earlier default settings with later user-specific ones. This cascading logic is a core configuration feature but lacks explicit tests to guarantee that dictionary merging and overriding behave exactly as documented (e.g., ensuring a setting in ~/.maigret/settings.json correctly overrides resources/settings.json without wiping out other keys).

Severity: medium
File: maigret/settings.py

Solution

Write a unit test using unittest.mock.patch on builtins.open and json.load to simulate reading multiple files with overlapping keys. Assert that the final Settings object contains the correctly merged values, prioritizing the later files in the paths list.

Changes

  • tests/test_settings.py (new)

Testing

  • Existing tests pass
  • Manual review completed
  • No new warnings/errors introduced


🤖 About this PR

This pull request was generated by ContribAI, an AI agent
that helps improve open source projects. The change was:

  1. Discovered by automated code analysis
  2. Generated by AI with context-aware code generation
  3. Self-reviewed by AI quality checks

If you have questions or feedback about this PR, please comment below.
We appreciate your time reviewing this contribution!

The `Settings.load()` method iterates through multiple configuration file paths and updates the internal `__dict__`, intending to override earlier default settings with later user-specific ones. This cascading logic is a core configuration feature but lacks explicit tests to guarantee that dictionary merging and overriding behave exactly as documented (e.g., ensuring a setting in `~/.maigret/settings.json` correctly overrides `resources/settings.json` without wiping out other keys).


Affected files: test_settings.py
@soxoj
Copy link
Copy Markdown
Owner

soxoj commented Mar 21, 2026

Thanks! 👍

@soxoj soxoj merged commit 0e95e2e into soxoj:main Mar 21, 2026
4 checks passed
soxoj pushed a commit that referenced this pull request Mar 22, 2026
The `Settings.load()` method iterates through multiple configuration file paths and updates the internal `__dict__`, intending to override earlier default settings with later user-specific ones. This cascading logic is a core configuration feature but lacks explicit tests to guarantee that dictionary merging and overriding behave exactly as documented (e.g., ensuring a setting in `~/.maigret/settings.json` correctly overrides `resources/settings.json` without wiping out other keys).


Affected files: test_settings.py
soxoj pushed a commit that referenced this pull request Apr 7, 2026
The `Settings.load()` method iterates through multiple configuration file paths and updates the internal `__dict__`, intending to override earlier default settings with later user-specific ones. This cascading logic is a core configuration feature but lacks explicit tests to guarantee that dictionary merging and overriding behave exactly as documented (e.g., ensuring a setting in `~/.maigret/settings.json` correctly overrides `resources/settings.json` without wiping out other keys).


Affected files: test_settings.py
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.

fix: missing tests for settings cascade and override logic

2 participants