Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add handling for missing isatty attr on stdout #50

Merged
merged 2 commits into from
Aug 15, 2023
Merged
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
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