Skip to content

Commit 3ba42e8

Browse files
pkchgvanrossum
authored andcommitted
Print pytest output as it happens (#3463)
Fix #3393 This results in pytest output being shown as a passthrough at the beginning of runtests.py.
1 parent 577dd99 commit 3ba42e8

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

mypy/waiter.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,20 @@ class LazySubprocess:
2525
"""Wrapper around a subprocess that runs a test task."""
2626

2727
def __init__(self, name: str, args: List[str], *, cwd: str = None,
28-
env: Dict[str, str] = None) -> None:
28+
env: Dict[str, str] = None, passthrough: bool = False) -> None:
2929
self.name = name
3030
self.args = args
3131
self.cwd = cwd
3232
self.env = env
3333
self.start_time = None # type: float
3434
self.end_time = None # type: float
35+
self.passthrough = passthrough
3536

3637
def start(self) -> None:
37-
self.outfile = tempfile.TemporaryFile()
38+
if self.passthrough:
39+
self.outfile = None
40+
else:
41+
self.outfile = tempfile.TemporaryFile()
3842
self.start_time = time.perf_counter()
3943
self.process = Popen(self.args, cwd=self.cwd, env=self.env,
4044
stdout=self.outfile, stderr=STDOUT)
@@ -47,6 +51,8 @@ def status(self) -> Optional[int]:
4751
return self.process.returncode
4852

4953
def read_output(self) -> str:
54+
if self.passthrough:
55+
return ''
5056
file = self.outfile
5157
file.seek(0)
5258
# Assume it's ascii to avoid unicode headaches (and portability issues).

runtests.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ def add_pytest(self, name: str, pytest_args: List[str], coverage: bool = False)
111111
else:
112112
args = [sys.executable, '-m', 'pytest'] + pytest_args
113113

114-
self.waiter.add(LazySubprocess(full_name, args, env=self.env), sequential=True)
114+
self.waiter.add(LazySubprocess(full_name, args, env=self.env, passthrough=True),
115+
sequential=True)
115116

116117
def add_python(self, name: str, *args: str, cwd: Optional[str] = None) -> None:
117118
name = 'run %s' % name

0 commit comments

Comments
 (0)