tests: consume fortinet query() as a FeedResult (fix red main) - #292
Merged
Conversation
…tion Two latent problems in test_fortinet_filter, both surfaced once #290 made modules/fortinet/feed.py parse again (the tests could not even run before): 1. FeedResult return. The FeedResult migration (c7acb1a) converted fortinet's query() to return feedutils.result(items, errors) but never updated this test, which still consumed the return value as a bare list -- so len() on the FeedResult counted its two fields (items, errors) instead of the posts, and every assertion was off. Unwrap via feedutils.split_result(), the same boundary the main loop uses. 2. Test isolation. feed.py imports its sibling `feedutils`; the test exec-loads feed.py by file path, so modules/ is only importable if some earlier test in the discovery order happened to put it on sys.path. Add modules/ to the path in _load_fortinet() so the test runs standalone too. No production code changes -- fortinet returning a FeedResult is correct (it is one of the 16 multi-source modules migrated in c7acb1a); the test had simply never been run against that contract.
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.
Problem
mainis currently red on thestdlib unittestcheck —test_fortinet_filterfails:Two latent problems, both surfaced once #290 made
modules/fortinet/feed.pyparse again (the tests couldn't run at all before, so this was never caught):c7acb1a) converted fortinet'squery()to returnfeedutils.result(items, errors)but never updated this test, which still consumed the return value as a bare list.len()on theFeedResultnamedtuple counts its two fields (items,errors) →2, not the number of posts, so every assertion was off.feed.pyimports its siblingfeedutils; the test exec-loadsfeed.pyby file path, somodules/is only importable if an earlier test in the discovery order happened to put it onsys.path. Run alone, it errored withModuleNotFoundError: feedutils.Fix
Test-only:
feedutils.split_result()— the same boundary the main loop uses.modules/tosys.pathin_load_fortinet()so the test runs standalone as well as under discovery.No production code change. fortinet returning a
FeedResultis correct — it's one of the 16 multi-source modules migrated inc7acb1a; the test had simply never been run against that contract.Testing
python -m unittest tests.test_fortinet_filter→ 4/4 pass in isolation;tests.test_fortinet_filter tests.test_feed_contracts tests.test_module_contracts→ 20/20.Follow-up to #290.