Permalink
Browse files

Add simple smoketest for page._detect_screen_size.

  • Loading branch information...
1 parent 366c633 commit 5ada34dfedbd1ce6ecc262fd681f870451c85607 @takluyver committed Oct 9, 2011
Showing with 22 additions and 1 deletion.
  1. +3 −1 IPython/core/page.py
  2. +19 −0 IPython/core/tests/test_page.py
View
@@ -31,6 +31,8 @@
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
@@ -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

0 comments on commit 5ada34d

Please sign in to comment.