Skip to content

Commit ed8e243

Browse files
committed
fix terminal dimension detection to work with stdout
--HG-- branch : trunk
1 parent 71cb42d commit ed8e243

File tree

5 files changed

+21
-3
lines changed

5 files changed

+21
-3
lines changed

CHANGELOG

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Changes between 1.3.2 and 1.3.3a1
2+
==================================================
3+
4+
- fix weirdness: make terminal width detection work on stdout instead of stdin
5+
(thanks Armin Ronacher for reporting)
6+
17
Changes between 1.3.1 and 1.3.2
28
==================================================
39

py/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
99
(c) Holger Krekel and others, 2004-2010
1010
"""
11-
__version__ = version = "1.3.2"
11+
__version__ = version = "1.3.3a1"
1212

1313
import py.apipkg
1414

py/_io/terminalwriter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
def _getdimensions():
2020
import termios,fcntl,struct
21-
call = fcntl.ioctl(0,termios.TIOCGWINSZ,"\000"*8)
21+
call = fcntl.ioctl(1,termios.TIOCGWINSZ,"\000"*8)
2222
height,width = struct.unpack( "hhhh", call ) [:2]
2323
return height, width
2424

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def main():
2626
name='py',
2727
description='py.test and pylib: rapid testing and development utils.',
2828
long_description = long_description,
29-
version= '1.3.2',
29+
version= '1.3.3a1',
3030
url='http://pylib.org',
3131
license='MIT license',
3232
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],

testing/io_/test_terminalwriter.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@ def test_get_terminal_width():
66
x = py.io.get_terminal_width
77
assert x == terminalwriter.get_terminal_width
88

9+
def test_getdimensions(monkeypatch):
10+
fcntl = py.test.importorskip("fcntl")
11+
import struct
12+
l = []
13+
monkeypatch.setattr(fcntl, 'ioctl', lambda *args: l.append(args))
14+
try:
15+
terminalwriter._getdimensions()
16+
except struct.error:
17+
pass
18+
assert len(l) == 1
19+
assert l[0][0] == 1
20+
921
def test_terminal_width_COLUMNS(monkeypatch):
1022
""" Dummy test for get_terminal_width
1123
"""

0 commit comments

Comments
 (0)