-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathconftest.py
32 lines (28 loc) · 897 Bytes
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import shutil
import tempfile
import subprocess
import pytest
from typing import List
@pytest.fixture
def make_tmpdir():
with tempfile.TemporaryDirectory() as tmpdirname:
yield tmpdirname
import logging
LOGGER = logging.getLogger(__name__)
@pytest.fixture
def run_command():
def _run(command: List[str], cwd: str) -> int:
executable = shutil.which(command[0])
assert executable
process = subprocess.run(
command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
executable=executable,
cwd=cwd,
check=True
)
LOGGER.info(process.stdout.decode("utf-8"))
LOGGER.error(process.stderr.decode("utf-8"))
return process.returncode
return _run