Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions objection/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""Run Objection as a Python module."""

from objection.console.cli import cli


if __name__ == "__main__":
cli()
29 changes: 29 additions & 0 deletions tests/test_module_entrypoint.py
Original file line number Diff line number Diff line change
@@ -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, "")