Files
pytest2/py/misc/testing/test_terminal.py
hpk abc8cf09aa [svn r57321] merging the event branch:
* moving in test, misc, code, io directories and
  py/__init__.py
* py/bin/_find.py does not print to stderr anymore
* a few fixes to conftest files in other dirs
some more fixes and adjustments pending

--HG--
branch : trunk
2008-08-16 17:26:59 +02:00

26 lines
625 B
Python

import os
import py
from py.__.misc.terminal_helper import get_terminal_width
def test_terminal_width():
""" Dummy test for get_terminal_width
"""
assert get_terminal_width()
try:
import fcntl
except ImportError:
py.test.skip('fcntl not supported on this platform')
def f(*args):
raise ValueError
ioctl = fcntl.ioctl
fcntl.ioctl = f
try:
cols = os.environ.get('COLUMNS', None)
os.environ['COLUMNS'] = '42'
assert get_terminal_width() == 41
finally:
fcntl.ioctl = ioctl
if cols:
os.environ['COLUMNS'] = cols