Skip to content

Commit bbd54e1

Browse files
committed
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.
1 parent 00f2065 commit bbd54e1

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/options.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ def _remove_negative_k(k):
6161

6262

6363
def _tty_width():
64+
if not hasattr(sys.stderr, "fileno"):
65+
return _atoi(os.environ.get('WIDTH')) or 70
6466
s = struct.pack("HHHH", 0, 0, 0, 0)
6567
try:
6668
import fcntl

0 commit comments

Comments
 (0)