Skip to content

Commit

Permalink
Add test for __main__.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Argmaster committed Nov 24, 2024
1 parent bc0526c commit 23e21e2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/pygerber/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@

from __future__ import annotations

import os
from contextlib import suppress

from pygerber.console.commands import main

if os.environ.get("COVERAGE_PROCESS_START") is not None:
with suppress(ImportError, ModuleNotFoundError):
import coverage

coverage.process_startup()


if __name__ == "__main__":
main()
23 changes: 23 additions & 0 deletions test/unit/test_gerber/test_console/test_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from __future__ import annotations

import logging
import os
import subprocess
import sys


def test_double_under_main_file() -> None:
result = subprocess.run( # noqa: S603
[sys.executable, "-m", "pygerber"],
executable=sys.executable,
env={**os.environ, "COVERAGE_PROCESS_START": ".coveragerc"},
check=False,
capture_output=True,
)

logging.info(result.stdout.decode())
logging.error(result.stderr.decode())

assert b"--version" in result.stdout
assert b"--help" in result.stdout
assert result.returncode == 0

0 comments on commit 23e21e2

Please sign in to comment.