Add internal state invariant tests and reorganize test directories#310
Merged
chrisguidry merged 3 commits intomainfrom Jan 27, 2026
Merged
Add internal state invariant tests and reorganize test directories#310chrisguidry merged 3 commits intomainfrom
chrisguidry merged 3 commits intomainfrom
Conversation
Adds tests that verify Worker and StrikeList internal data structures are properly cleaned up after task completion and context exit. These tests would have caught the memory leak fixed in #309 where `_tasks_by_key` entries accumulated because we were using `task.get_name()` instead of `execution.key` for cleanup. Worker invariant tests check: - `_tasks_by_key` is empty after `run_until_finished()` - `_tasks_by_key` doesn't grow across multiple batches - `_execution_counts` is cleared after `run_at_most()` - Internal attributes are deleted after `__aexit__` - Cleanup works with failing tasks and varied task types - SharedContext ContextVars are properly reset StrikeList invariant tests check: - `_conditions` only contains default after removing temp conditions - No empty dicts remain in `task_strikes`/`parameter_strikes` after restore Also reorganizes tests into subdirectories: - `tests/worker/` for worker-related tests - `tests/instrumentation/` for metrics and tracing tests - Renames `test_synced_strikelist.py` to `test_strikelist.py` Adds `--import-mode=importlib` to pytest config to support same-named test files in different directories. Co-Authored-By: Claude Opus 4.5 <[email protected]>
|
📚 Documentation has been built for this PR! You can download the documentation directly here: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #310 +/- ##
==========================================
+ Coverage 98.61% 98.63% +0.02%
==========================================
Files 99 100 +1
Lines 9906 10066 +160
Branches 483 491 +8
==========================================
+ Hits 9769 9929 +160
Misses 121 121
Partials 16 16
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
The `logging.LoggerAdapter[logging.Logger]` type hint needs PEP 563 deferred evaluation to work on Python 3.10. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Simplify the SharedContext reset test and use a typed lambda for the temporary condition test to avoid uncovered branches. Co-Authored-By: Claude Opus 4.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds tests that verify Worker and StrikeList internal data structures are
properly cleaned up after task completion and context exit. These tests
would have caught the memory leak fixed in #309 where
_tasks_by_keyentries accumulated because we were using
task.get_name()instead ofexecution.keyfor cleanup.Worker invariant tests check:
_tasks_by_keyis empty afterrun_until_finished()_tasks_by_keydoesn't grow across multiple batches_execution_countsis cleared afterrun_at_most()__aexit__StrikeList invariant tests check:
_conditionsonly contains default after removing temp conditionstask_strikes/parameter_strikesafter restoreAlso reorganizes tests into subdirectories:
tests/worker/for worker-related teststests/instrumentation/for metrics and tracing teststest_synced_strikelist.pytotest_strikelist.pyAdds
--import-mode=importlibto pytest config to support same-namedtest files in different directories.
🤖 Generated with Claude Code