Skip to content

Commit

Permalink
Merge pull request #50 from sot/pyexec-stdout
Browse files Browse the repository at this point in the history
Add handling for missing isatty attr on stdout
  • Loading branch information
jeanconn authored Aug 15, 2023
2 parents 4df4f38 + f4de2f4 commit e00f29c
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions testr/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@
import os


# Make a class to wrap sys.stdout to handle requests for isatty. This is needed
# to get the right output from pytest when run from FOT MATLAB pyexec.
# Borrowed from https://github.com/pytest-dev/pytest/issues/5462
class StdOutWrapper:

def __init__(self, stdout):
self._stdout = stdout

def __getattr__(self, item):
return getattr(self._stdout, item)

def isatty(self):
return False


class TestError(Exception):
pass

Expand Down Expand Up @@ -65,6 +80,9 @@ def test(*args, **kwargs):
import pytest
import contextlib

# Use the StdOutWrapper to make sure that isatty returns something for sys.stdout
sys.stdout = StdOutWrapper(sys.stdout)

# Copied from Ska.File to reduce import footprint and limit to only standard
# modules.
@contextlib.contextmanager
Expand Down

0 comments on commit e00f29c

Please sign in to comment.