Repository navigation
Conversation
BaseTest turned pook on and registered its mocks in setUpClass but never turned pook off, so every class's mocks stayed active for the rest of the run. That hid a problem in two tests. test_list_stocks_dividends_ticker_any_of and test_get_snapshot_indices each send the same request twice, but each mock answers only once. Their second request was answered by a copy that an earlier class had registered, so both fail with PookNoMatches when their module runs on its own. Turn pook off in tearDownClass. Let a test class name the mocks that must answer more than once, and register those with persist. Other mocks still answer once, because the pagination tests rely on it: a first-page mock also matches the request for the next page.
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Comment |
This was referenced Oct 24, 2026
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.
Fixes #<issue: POOK-MOCK-LEAK>
BaseTestturns pook on and registers its mocks insetUpClass, but never turns pook off. Every class's mocks stay active for the rest of the run.That hides a bug in two tests. Each sends the same request twice, and each mock answers once, so the second request is answered by a mock left over from an earlier class. Run alone on
master, both fail:BaseTest.tearDownClasscallspook.off(), which stops interception and drops the class's mocks.persistent_mocks; those are registered withpersist=True. The two tests above use it.Tests only; the package does not change.
Tests
test_dividendsandtest_snapshotspass when run on their own.make testandmake lintpass on 3.10 and 3.14.