From 5ada34dfedbd1ce6ecc262fd681f870451c85607 2011-10-09 18:03:26 From: Thomas Kluyver Date: 2011-10-09 18:03:26 Subject: [PATCH] Add simple smoketest for page._detect_screen_size. --- diff --git a/IPython/core/page.py b/IPython/core/page.py index 91dd5e2..8a98fee 100644 --- a/IPython/core/page.py +++ b/IPython/core/page.py @@ -31,6 +31,8 @@ import re import sys import tempfile +from io import UnsupportedOperation + from IPython.core import ipapi from IPython.core.error import TryNext from IPython.utils.cursesimport import use_curses @@ -180,7 +182,7 @@ def page(strng, start=0, screen_lines=0, pager_cmd=None): if screen_lines <= 0: try: screen_lines += _detect_screen_size(use_curses, screen_lines_def) - except Exception: + except (TypeError, UnsupportedOperation): print >>io.stdout, str_toprint return diff --git a/IPython/core/tests/test_page.py b/IPython/core/tests/test_page.py new file mode 100644 index 0000000..28b23f8 --- /dev/null +++ b/IPython/core/tests/test_page.py @@ -0,0 +1,19 @@ +#----------------------------------------------------------------------------- +# Copyright (C) 2010 The IPython Development Team. +# +# Distributed under the terms of the BSD License. +# +# The full license is in the file COPYING.txt, distributed with this software. +#----------------------------------------------------------------------------- +import io + +from IPython.core import page + +def test_detect_screen_size(): + """Simple smoketest for page._detect_screen_size.""" + try: + page._detect_screen_size(True, 25) + except (TypeError, io.UnsupportedOperation): + # This can happen in the test suite, because stdout may not have a + # fileno. + pass