Skip to content
Merged
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
4 changes: 2 additions & 2 deletions src/deadcode/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Allow running deadcode as: python -m deadcode"""
from deadcode.cli import main
from deadcode.cli import cli

if __name__ == "__main__":
main()
cli()
16 changes: 16 additions & 0 deletions tests/test_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pytest
from deadcode.cli import cli
from deadcode.scanner import DeadCodeScanner
from pathlib import Path


@pytest.fixture
Expand Down Expand Up @@ -292,3 +293,18 @@ def test_stats_command(self, runner, sample_project):
assert result.exit_code == 0
assert "Files scanned" in result.output
assert "Unused exports" in result.output

def test_main_module_entry_point(self, runner):
"""Test that python -m deadcode works (__main__ entry point fix)."""
import subprocess
import sys
result = subprocess.run(
[sys.executable, "-m", "deadcode", "--help"],
capture_output=True, text=True,
cwd=str(Path(__file__).parent.parent / "src"),
)
assert result.returncode == 0
assert "DeadCode" in result.stdout
assert "scan" in result.stdout
assert "remove" in result.stdout
assert "stats" in result.stdout
Loading