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
5 changes: 5 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ $ pipx install --suffix=@next g --pip-args '\--pre' --force

- Add docstrings to functions, methods, classes, and packages (#18)

### Bug fixes

- Prevent outputting `<Popen: returncode: 1 args: ['git']>` when running `g`
(#19)

## g 0.0.2 (2022-09-11)

**Maintenance only release, no bug fixes or features**
Expand Down
15 changes: 15 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""Setup pytest for g."""
import pytest


@pytest.fixture(autouse=True)
def setup(monkeypatch: pytest.MonkeyPatch) -> None:
"""Prepare pytest test environment.

Environment variables
---------------------
G_IS_TEST :
Control whether run() returns proc so function can be tested. If proc was always
returned, it would print *<Popen: returncode: 1 args: ['git']>* after command.
"""
monkeypatch.setenv("G_IS_TEST", "1")
12 changes: 10 additions & 2 deletions src/g/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python
"""Package for g."""
import os
import pathlib
import subprocess
import sys
Expand Down Expand Up @@ -29,7 +30,14 @@ def run(
*args: object,
**kwargs: t.Any,
) -> t.Optional["subprocess.Popen[str]"]:
"""CLI Entrypoint for g, overlay for current directory's VCS utility."""
"""CLI Entrypoint for g, overlay for current directory's VCS utility.

Environment variables
---------------------
G_IS_TEST :
Control whether run() returns proc so function can be tested. If proc was always
returned, it would print *<Popen: returncode: 1 args: ['git']>* after command.
"""
# Interpret default kwargs lazily for mockability of argv
if cmd is DEFAULT:
cmd = find_repo_type(pathlib.Path.cwd())
Expand All @@ -44,7 +52,7 @@ def run(
proc.wait()
else:
proc.communicate()
if __name__ != "__main__":
if os.getenv("G_IS_TEST") and __name__ != "__main__":
return proc
return None

Expand Down