Skip to content

bug(test): four helpers resolve to nothing and report success — one imports nothing while claiming to import a module #15251

Description

@mrveiss

Found while fixing #15181. Four test helpers that resolve to nothing and report success, in three different shapes.

path:line What it claims What it does
autobot-backend/tests/unit/test_agents_status_pg_optional.py:54,61 _import_func imports api/agent_org.py Anchors parents[3] where the module is at parents[2], and discards the spec and return None at :61. It imports nothing, and the wrong path never surfaces because of it
autobot-infrastructure/shared/tests/conftest.py:106 test_data_dir fixture → Path(__file__).parent / "fixtures" / "data" That directory does not exist
autobot-backend/conftest.py:1387 Same fixture, same shape → .../tests/fixtures/data Also missing
repo_tests/trivial_config_test.py:18 sys.path entry for autobot-backend Resolves to repo_tests/autobot-backend; should be .parent.parent. A path entry supplying nothing

Why these are worse than a broken path

A wrong path that raises gets fixed the first time someone runs the test. These do not raise:

Related, not duplicated

#15181 fixed one parents[N] anchor and added repo_tests/test_module_path_anchors_15181_test.py, an AST sweep over 111 anchored data-file expressions across the repository. It reaches modules by parsing rather than running, so it sees files hidden behind collection errors. It found exactly one unresolved anchor after the fix — the _import_func entry above, carried as its single grandfathered KNOWN_UNRESOLVED entry.

Directory-valued anchors are deliberately outside that guard, which is why the two test_data_dir fixtures are not caught by it. That exemption is worth revisiting as part of this issue: a fixture returning a missing directory is exactly as silent as a file anchor pointing at nothing.

Acceptance criteria

  • _import_func either imports what it names or is removed. If anything depended on its None return, that dependency is the real finding — report it.
  • Fix its parents[3] anchor, and remove the KNOWN_UNRESOLVED grandfather entry in the same change rather than leaving it recorded.
  • Both test_data_dir fixtures point at a directory that exists, or are removed. Establish first whether anything consumes them — a fixture nobody uses is a different fix from one whose consumers have been quietly getting nothing.
  • trivial_config_test.py:18 resolves to the real autobot-backend, and what it was supposed to enable is confirmed to work.
  • Decide whether the anchor guard should cover directory-valued anchors. If not, record why here so the exemption is a decision rather than an omission.
  • Contrast mutations for whatever guard covers these.

Refs #15181, #15018, #15189, #15178, PR #15249.

Activity

  1. mrveiss commented on Aug 31, 2026

    @mrveiss
    OwnerAuthor

    Closing — all four helpers fixed. 8fa01bf0e3 (PR #15351), verified against merged Dev_new_gui.

    Site Fix on merged base
    tests/unit/test_agents_status_pg_optional.py:54,61 anchors at parents[2] (:60), and now raises instead of returning None — ImportError when the module is absent (:62), ImportError when the spec cannot be built (:66), AttributeError for a missing attribute (:72)
    autobot-infrastructure/shared/tests/conftest.py:106 test_data_dir fixture removed — zero consumers confirmed first
    autobot-backend/conftest.py:1387 same fixture, same removal
    repo_tests/trivial_config_test.py:18 anchor corrected; the prior .parent / "autobot-backend" resolved to a non-existent repo_tests/autobot-backend and supplied nothing

    The core of this issue was that a helper returning a falsy value on failure hides the bug that caused it — the wrong parents[3] anchor never surfaced precisely because the enclosing function discarded the spec and returned None. Every one of these now fails loudly.

    The KNOWN_UNRESOLVED grandfather entry was not merely deleted — it was replaced with a regression pin (test_module_path_anchors_15181_test.py:263-272) asserting the anchor stays at parents[2], so the guard catches a regression directly rather than only via the swallow it used to hide behind. That is a better outcome than removal, because it stops the shape regrowing silently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtesting

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions