From 0f90c82ee6452f810fe9a91943f8efde91404355 Mon Sep 17 00:00:00 2001 From: Yon Liud Date: Tue, 1 Sep 2026 15:15:53 +0300 Subject: [PATCH] Add Python module entry point --- objection/__main__.py | 7 +++++++ tests/test_module_entrypoint.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 objection/__main__.py create mode 100644 tests/test_module_entrypoint.py diff --git a/objection/__main__.py b/objection/__main__.py new file mode 100644 index 00000000..12d2fe76 --- /dev/null +++ b/objection/__main__.py @@ -0,0 +1,7 @@ +"""Run Objection as a Python module.""" + +from objection.console.cli import cli + + +if __name__ == "__main__": + cli() diff --git a/tests/test_module_entrypoint.py b/tests/test_module_entrypoint.py new file mode 100644 index 00000000..4a812193 --- /dev/null +++ b/tests/test_module_entrypoint.py @@ -0,0 +1,29 @@ +import os +import subprocess +import sys +import tempfile +import unittest +from pathlib import Path + +from objection import __version__ + + +class TestsModuleEntrypoint(unittest.TestCase): + def test_module_entrypoint_runs_cli(self): + with tempfile.TemporaryDirectory() as home: + Path(home, ".objection").mkdir() + env = os.environ.copy() + env["HOME"] = home + env["USERPROFILE"] = home + + result = subprocess.run( + [sys.executable, "-m", "objection", "version"], + capture_output=True, + check=False, + text=True, + env=env, + ) + + self.assertEqual(result.returncode, 0) + self.assertTrue(result.stdout.endswith(f"objection: {__version__}\n")) + self.assertEqual(result.stderr, "")