Check for fileno attribute in _tty_width function

When using Options parser within a unittest.TextTestRunner with buffering enabled (buffer=True), it fails with: 
AttributeError: StringIO instance has no attribute 'fileno'

This change will prevent this kind of error.
This commit is contained in:
jbd 2015-05-12 16:43:38 +02:00
parent 00f20657e3
commit bbd54e150d

View File

@ -61,6 +61,8 @@ def _remove_negative_k(k):
def _tty_width(): def _tty_width():
if not hasattr(sys.stderr, "fileno"):
return _atoi(os.environ.get('WIDTH')) or 70
s = struct.pack("HHHH", 0, 0, 0, 0) s = struct.pack("HHHH", 0, 0, 0, 0)
try: try:
import fcntl import fcntl