Skip to content

perf: Speed up unit tests via fixture scoping and reduced filesystem I/O#82

Merged
Jammy2211 merged 1 commit intomainfrom
feature/speed-up-unit-tests
Apr 6, 2026
Merged

perf: Speed up unit tests via fixture scoping and reduced filesystem I/O#82
Jammy2211 merged 1 commit intomainfrom
feature/speed-up-unit-tests

Conversation

@Jammy2211
Copy link
Copy Markdown
Collaborator

Summary

Reduces PyAutoConf test suite time by ~40% through three targeted optimizations:

  • Session-scoped config fixture for read-only tests (eliminates redundant Config init)
  • Early-exit os.walk in Config.push() (stops after first config file match)
  • Cached os.listdir in RecursiveConfig (replaces 4 stat calls per lookup with set membership check)

All 71 tests pass. Downstream suites verified: PyAutoGalaxy (852 passed), PyAutoLens (286 passed).

API Changes

None — internal changes only. The public API of Config, RecursiveConfig, and all other classes is unchanged. The optimizations only affect internal filesystem access patterns.

Test Plan

  • All 71 PyAutoConf tests pass
  • PyAutoGalaxy (852 tests) passes
  • PyAutoLens (286 tests) passes
  • Median runtime reduced from ~6.1s to ~3.8s across stable runs
Full API Changes (for automation & release notes)

Removed

(none)

Added

  • RecursiveConfig.listing property — cached os.listdir result (internal, not public API)

Changed Behaviour

  • Config.push() — validation walk now exits early on first config file match instead of collecting all suffixes. Same error raised for invalid paths.
  • RecursiveConfig._getitem() — uses cached directory listing instead of individual stat calls. Same lookup semantics.

Migration

No migration needed — all changes are internal.

🤖 Generated with Claude Code

- Add session-scoped config fixture for read-only tests in test_default.py
- Early-exit os.walk in Config.push() — stop after first config file found
- Cache os.listdir in RecursiveConfig to eliminate redundant stat calls
- Reduces test suite time from ~6s to ~3.5s (40% faster)

Closes #81

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Jammy2211 Jammy2211 merged commit ccf2f36 into main Apr 6, 2026
2 checks passed
@Jammy2211 Jammy2211 deleted the feature/speed-up-unit-tests branch April 6, 2026 15:28
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.

1 participant