Repository navigation
CI: don't leak PySB symbols from tests - #591
Merged
Merged
Conversation
`pysb.SelfExporter.cleanup()` does not remove a model exported under an
explicit name, e.g. `pysb.Model("test_model")`. The model remained in the
test module's globals, and a later test defining a model of the same
name failed with `SymbolExistsWarning`.
Replace the duplicated `uses_pysb` fixtures with a shared
`clean_pysb_exports` fixture that also removes the named model and fails
if other exported PySB symbols remain.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
dweindl
marked this pull request as ready for review
November 16, 2026 14:28
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.
pysb.SelfExporter.cleanup()does not remove a model exported under an explicit name (e.g.pysb.Model("test_model")). The model remained in the test module's globals, so a later test defining a model with the same name failed withSymbolExistsWarning(an error due tofilterwarnings = error), depending on test order.The duplicated
uses_pysbfixtures intests/v1/test_model_pysb.pyandtests/v2/test_lint.pyare replaced by a sharedclean_pysb_exportsfixture intests/conftest.py. It additionally removes the named model, and fails (after removing them) if any other exported PySB symbols remain, so future leaks surface at the leaking test. It yields the cleanup function for use within a test, as needed intest_check_mapping_table.🤖 Generated with Claude Code