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
Refs #15181, #15018, #15189, #15178, PR #15249.
Found while fixing #15181. Four test helpers that resolve to nothing and report success, in three different shapes.
path:lineautobot-backend/tests/unit/test_agents_status_pg_optional.py:54,61_import_funcimportsapi/agent_org.pyparents[3]where the module is atparents[2], and discards the spec andreturn Noneat:61. It imports nothing, and the wrong path never surfaces because of itautobot-infrastructure/shared/tests/conftest.py:106test_data_dirfixture →Path(__file__).parent / "fixtures" / "data"autobot-backend/conftest.py:1387.../tests/fixtures/datarepo_tests/trivial_config_test.py:18sys.pathentry forautobot-backendrepo_tests/autobot-backend; should be.parent.parent. A path entry supplying nothingWhy 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:
_import_funcmasks its own defect — the anchor is off by one, but because the helper discards the result and returnsNone, nothing ever notices. Any assertion downstream is testingNone. It is the shape test(quality): ten tests that could not fail — bare 'except Exception' swallowing AssertionError, and one asserting imports it never performed #15189 documented (a test that cannot fail), reached by a different route.sys.pathentry pointing at nothing does not error; it just fails to make imports work, and whatever depended on it either skips or falls back.Related, not duplicated
#15181 fixed one
parents[N]anchor and addedrepo_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_funcentry above, carried as its single grandfatheredKNOWN_UNRESOLVEDentry.Directory-valued anchors are deliberately outside that guard, which is why the two
test_data_dirfixtures 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_funceither imports what it names or is removed. If anything depended on itsNonereturn, that dependency is the real finding — report it.parents[3]anchor, and remove theKNOWN_UNRESOLVEDgrandfather entry in the same change rather than leaving it recorded.test_data_dirfixtures 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:18resolves to the realautobot-backend, and what it was supposed to enable is confirmed to work.Refs #15181, #15018, #15189, #15178, PR #15249.