import sys from subprocess import run from unittest import TestCase class TestCli(TestCase): """Test the cli module.""" def test_entry_points(self): """Tests that entrypoints are correctly defined and work both as __main__ and sub-commands.""" modules = [ "powertrain_build.wrapper", "powertrain_build.interface.generate_adapters", "powertrain_build.interface.generate_hi_interface", "powertrain_build.interface.generate_service", "powertrain_build.interface.generate_wrappers", "powertrain_build.interface.model_yaml_verification", "powertrain_build.interface.update_model_yaml", "powertrain_build.interface.update_call_sources", ] for module in modules: entrypoint = module.replace("_", "-").split(".") run(entrypoint + ["--help"], check=True) run([sys.executable, "-m", module, "--help"], check=True)