import subprocess import sys from pathlib import Path ROOT = Path(__file__).resolve().parents[2] def test_source_preflight_handles_recursive_yaml_lists_without_host_packages(): source = ROOT / 'scripts/prepare_controller_hub_release_volume.py' program = """ import importlib.util, sys spec = importlib.util.spec_from_file_location('controller', sys.argv[1]) module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module) module._preflight_source_compose(b'services: {deploy-control: {image: fixed}}\\nx-loop: &a [*a]\\n') try: module._preflight_source_compose(b'services: {deploy-control: {image: fixed}}\\nx-loop: &a [*a, {env_file: /tmp/secret}]\\n') except module.VolumeTransitionError as error: assert str(error) == 'controller_volume_external_source_invalid' else: raise AssertionError('external source inside alias accepted') """ result = subprocess.run([sys.executable, '-I', '-S', '-c', program, str(source)], capture_output=True, text=True, timeout=15, check=False) assert result.returncode == 0, result.stderr