Repository navigation
Mark unmarked live-network tests as network (#397) - #509
Merged
Merged
Conversation
tests/test_knowledge/test_papers_sync.py's TestPapersSync makes real OpenAlex calls through opencite but carried no marker, so the standard local filter (-m "not llm and not integration and not network and not slow") selected it; a slow or unreachable OpenAlex hung the suite indefinitely. TestLivePaperSearch was the same, just already carrying its own timeout kwarg. sync_openalex_papers() had no way to bound the opencite request, so give it an explicit timeout that forwards to opencite's own Config (mirrors search_papers_live's existing timeout parameter). The two TestPapersSync tests now pass timeout=15. Tested: -m "not llm and not integration and not network and not slow" deselects all 3; -m network runs all 3 against the live OpenAlex API in under 1s each. ruff check and format clean.
tests/test_tools/test_tool_integration.py fetches real documentation URLs (no respx mock) in several tests without a network marker: the preloaded/on-demand retrieve_docs tests, the citations success path, the whole TestDocumentFetcher class, and the "handles network error gracefully" test (which still does a real fetch). None hang -- the underlying DocumentFetcher already bounds each request to 30s -- but they still spend the local suite's time on a live request and depend on external hosts being reachable. Left unmarked: tests that never reach the network (unknown-URL lookups short-circuit in the doc registry before any fetch) and the respx-mocked chrome-only-page tests, which exercise the same code path against a fake response. Tested: -m "not llm and not integration and not network and not slow" deselects all 7; -m network runs all 7 against the live docs, passing. ruff check and format clean.
tests/test_tools/test_fetcher.py's module docstring claimed every test needs network access, but only 5 of its TestDocumentFetcher methods actually call fetcher.fetch() against a real URL (GitHub raw content, or a nonexistent repo to check the 404 path); the rest exercise the cache layer with synthetic data. Mark just the five live ones and correct the docstring. Tested: -m "not llm and not integration and not network and not slow" deselects all 5; -m network runs all 5 against GitHub, passing. ruff check and format clean.
Found during the #397 sweep: tests/test_knowledge/test_github_sync.py carries the same "real API tests, not mocks" note as test_papers_sync.py but had no network marker on the tests that hit the real GitHub API (sync_repo_issues/sync_repo against hed-standard/hed-specification, and the GITHUB_TOKEN-gated variant). They tolerate a failed request and return 0 rather than hanging or raising, so they weren't caught by re-running the offline suite with the network blocked, but they still reach api.github.com from what is supposed to be an offline run. Tested: -m "not llm and not integration and not network and not slow" deselects the 3 marked tests; -m network runs them against the live GitHub API (2 pass, 1 skips for missing GITHUB_TOKEN as before). ruff check and format clean.
14 of 24 tasks
sync_repos(['nonexistent/repo']) makes real unauthenticated GitHub requests, so it belongs with the other live tests (#397 review). Tested: test_github_sync.py -m 'not network' passes with it deselected; ruff check and format clean.
This was referenced Sep 25, 2026
Merged
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.
Summary
Closes #397.
tests/test_knowledge/test_papers_sync.py::TestPapersSyncmade real OpenAlex calls through opencite with nonetworkmarker, so the standard local filter (-m "not llm and not integration and not network and not slow") selected it, and a slow or unreachable OpenAlex could hang the local suite indefinitely (observed: 12+ minutes on one test, socket inCLOSE_WAIT).This PR marks that class and every other unmarked live-network test found by measurement (running the offline selection with outbound network forced to fail fast via
HTTPS_PROXY=http://127.0.0.1:9, plus--durationsto catch slow ones proxy-blocking might miss), and gives the OpenAlex sync calls an explicit, bounded timeout.Tests marked
networktests/test_knowledge/test_papers_sync.pyTestPapersSync(class):test_sync_openalex_papers_basic,test_sync_respects_max_resultsTestLivePaperSearch(class):test_live_search_returns_recenttests/test_tools/test_tool_integration.py(issue explicitly names this file's retrieve-docs tests)TestRetrieveDocsTool::test_retrieve_preloaded_doc_successTestRetrieveDocsTool::test_retrieve_ondemand_doc_successTestRetrieveDocsToolCitations::test_returns_search_result_block_on_successTestDocumentFetcher(class):test_fetcher_returns_content_for_known_doc,test_fetcher_handles_invalid_doc,test_fetcher_caches_resultsTestErrorHandling::test_retrieve_tool_handles_network_error_gracefullytests/test_tools/test_fetcher.py(TestDocumentFetcherclass, 5 of its methods that hit a real URL; the module docstring overclaimed "every test needs network," corrected it)test_fetch_real_document,test_fetch_caches_result,test_fetch_invalid_url,test_fetch_many,test_preloadtests/test_knowledge/test_github_sync.py(additional finding from the sweep, same anti-pattern astest_papers_sync.py: real GitHub API calls, no marker)TestGitHubSync::test_sync_repo_issues_basic_flow,test_sync_repo_full_flow,test_sync_with_tokenLeft unmarked (verified they never touch the network): unknown-URL lookups that short-circuit in the doc registry before any fetch, the
respx-mocked chrome-only-page tests,test_fetch_uses_cache(pre-populates the cache, never fetches), and all theTestDocumentFetcher/TestGetFetchercache-only tests intest_fetcher.py.Timeout
sync_openalex_papers()had no way to bound its opencite request. Added an optionaltimeoutparameter (forwarded to opencite's ownConfig.timeout, mirroring the patternsearch_papers_livealready used) so the twoTestPapersSynctests can passtimeout=15and fail fast instead of relying on opencite's internal defaults. The other three files already had an explicit, bounded client-side timeout (DocumentFetcher.timeout_seconds/_github_request'stimeoutparam), so no source changes were needed there.pytest-timeoutis not used anywhere in this repo (checkedpyproject.tomland all workflows), so it was not added.CI: unchanged in effect
.github/workflows/tests.yml(testjob, runs on every push/PR todevelop/main) selects-m "not network": it already excluded nothing extra for these tests before this change beyond what "not network" always meant; after this change these tests are properly excluded, matching the local filter..github/workflows/test.yml'sintegration-testsjob has a "Run network tests" step (pytest tests/ -v -m "network" --tb=short,continue-on-error: true) with no path restriction, gated to push-to-main/workflow_dispatch. It already coverstests/broadly, so it picks up every test marked here with no workflow edit needed, exactly as it already does for the HED validation tests marked in Mark the live HED validation tests as network #486.Measurement
Offline selection with network forced to fail immediately:
--durationsoutput also showed the three now-markedtest_papers_sync.pytests as the three slowest in the run (~7s each, consistent with retry/backoff against the blocked proxy).tests/test_cli/test_main.py::TestVersionCommand::test_version_shows_version, an ANSI-color-code assertion unrelated to network, present before and after this change, not touched here), 2940 passed, 13 skipped, 103 deselected (+18, matching every test marked above), 22.1s.test_github_sync.py's tests were found separately: they tolerate a failed request (assert count >= 0) so they don't fail under the blocked proxy, but code inspection plus a live run confirmed they reachapi.github.comfor real; included for the same reasontest_papers_sync.pywas.Live run of every newly marked test against the real services (
-m network): 17 passed, 1 skipped (test_sync_with_token, noGITHUB_TOKENset locally, same as before this change).Test plan
uv run pytest tests/ -q -m "not llm and not integration and not network and not slow" -p no:cacheproviderwith network blocked: 2940 passed, 1 pre-existing unrelated failure, 13 skipped, 103 deselected, 22.1s (no hang)uv run pytest tests/test_knowledge/test_papers_sync.py tests/test_tools/test_tool_integration.py tests/test_tools/test_fetcher.py tests/test_knowledge/test_github_sync.py -m networkagainst the live services: all pass (1 skip for missingGITHUB_TOKEN)uv run ruff check .uv run ruff format --check src teststest.yml's network job (-m "network", no path filter) still covers every test marked in this PR; no workflow files changed