You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug(slm-tests): test_wizard_inventory_parity_14286.py's ad-hoc loader breaks on services.role_manifest_shape import #17164
autobot-slm-backend/tests/services/test_wizard_inventory_parity_14286.py fails at collection, standalone, unrelated to any change in this session:
tests/services/test_wizard_inventory_parity_14286.py:121: in <module>
_ib, _rr, _pe, _wiz = _load()
tests/services/test_wizard_inventory_parity_14286.py:96: in _load
role_registry = _real_module("_rr_14286", _BACKEND_ROOT / "services" / "role_registry.py")
tests/services/test_wizard_inventory_parity_14286.py:56: in _real_module
spec.loader.exec_module(module)
services/role_registry.py:21: in <module>
from services.role_manifest_shape import default_roles_for
E ModuleNotFoundError: No module named 'services.role_manifest_shape'; 'services' is not a package
Cause (as far as static reading shows)
_real_module() loads services/role_registry.py directly via importlib.util.spec_from_file_location, bypassing services/__init__.py (presumably to avoid its own heavy imports, same reason other test files in this dir do this). But role_registry.py itself does a package-relative from services.role_manifest_shape import default_roles_for -- that resolves only if sys.modules['services'] is already registered as a proper package (with __path__), which this ad-hoc load never sets up.
Confirmed unrelated to #17150/#17163 (playbook_executor.py's ansible_dir caching fix): zero diff between origin/main and that PR's branch for role_registry.py, role_manifest_shape.py, or this test file itself. Reproduced standalone: python3 -m pytest autobot-slm-backend/tests/services/test_wizard_inventory_parity_14286.py.
Not yet determined
Whether this also fails in CI's python-suite shards (I could not check without derailing a priority task) or is masked there by shard/collection order, a conftest that pre-populates sys.modules['services'], or an environment difference from my local repro. Leaving that unticked rather than guessing.
Acceptance criteria
test_wizard_inventory_parity_14286.py collects and its tests run cleanly in a fresh interpreter, standalone.
Confirm whether this fails in CI today as well, or only locally, and say why.
Sighting (2026-10-12, while finishing #18094 on a tree rebased onto current main): the same ad-hoc-loader class now fails collection in three files, with a second missing stub: services.playbook_output_stream (imported by services/playbook_executor.py:34 since #17318).
Each stubs services with a MagicMock and lists only the submodules it knew about, so every new import in playbook_executor.py breaks all three. Fixing the class once (a shared loader that stubs what the executor imports, or loading it as a real package) covers all of them. Not fixed on #18094: it touches none of these files.
Activity
fix(tests): set _ansible_dir_explicit on the __init__-skipping test d…
mrveiss commentedon Oct 11, 2026
Sighting (2026-10-12, while finishing #18094 on a tree rebased onto current main): the same ad-hoc-loader class now fails collection in three files, with a second missing stub:
services.playbook_output_stream(imported byservices/playbook_executor.py:34since #17318).autobot-slm-backend/tests/services/test_self_update_systemd_detach_11492.pyNo module named 'services.playbook_output_stream'; 'services' is not a packageautobot-slm-backend/tests/services/test_dynamic_inventory_group_vars_11781.pyautobot-slm-backend/tests/services/test_wizard_inventory_parity_14286.pyEach stubs
serviceswith a MagicMock and lists only the submodules it knew about, so every new import inplaybook_executor.pybreaks all three. Fixing the class once (a shared loader that stubs what the executor imports, or loading it as a real package) covers all of them. Not fixed on #18094: it touches none of these files.