nix-direnv/tests/procs.py
Andrew Marshall 857bcd5c4f Remove unneeded shebangs from test files
The files are not executable, tests should only be run via `pytest`, and
some of them were incorrectly python2.
2023-04-14 12:43:34 -04:00

23 lines
586 B
Python

import subprocess
from pathlib import Path
from typing import IO, Any, List, Optional, Union
_FILE = Union[None, int, IO[Any]]
_DIR = Union[None, Path, str]
def run(
cmd: List[str],
text: bool = True,
check: bool = True,
cwd: _DIR = None,
stderr: _FILE = None,
stdout: _FILE = None,
env: Optional[dict[str, str]] = None,
) -> subprocess.CompletedProcess:
if cwd is not None:
print(f"cd {cwd}")
print("$ " + " ".join(cmd))
return subprocess.run(
cmd, text=text, check=check, cwd=cwd, stderr=stderr, stdout=stdout, env=env
)