2734763
From 919ba5d0fedf4a7c64bd22627b47d11404f41221 Mon Sep 17 00:00:00 2001
70a8475
From: Dan Callaghan <dcallagh@redhat.com>
70a8475
Date: Fri, 30 Nov 2012 14:05:04 +1000
2734763
Subject: [PATCH 1/2] fix tests when run without a tty (fixes #25)
70a8475
70a8475
---
2734763
 blessings/tests.py | 8 +++++---
2734763
 1 file changed, 5 insertions(+), 3 deletions(-)
70a8475
70a8475
diff --git a/blessings/tests.py b/blessings/tests.py
2734763
index a03eb8d..da1a71b 100644
70a8475
--- a/blessings/tests.py
70a8475
+++ b/blessings/tests.py
2734763
@@ -43,6 +43,8 @@ def test_capability():
70a8475
 
70a8475
     """
70a8475
     t = TestTerminal()
70a8475
+    if not t.is_a_tty:
70a8475
+        raise SkipTest
70a8475
     sc = unicode_cap('sc')
70a8475
     eq_(t.save, sc)
70a8475
     eq_(t.save, sc)  # Make sure caching doesn't screw it up.
70a8475
@@ -64,7 +66,7 @@ def test_capability_with_forced_tty():
70a8475
 
70a8475
 def test_parametrization():
70a8475
     """Test parametrizing a capability."""
70a8475
-    eq_(TestTerminal().cup(3, 4), unicode_parm('cup', 3, 4))
70a8475
+    eq_(TestTerminal(force_styling=True).cup(3, 4), unicode_parm('cup', 3, 4))
70a8475
 
70a8475
 
2734763
 def test_height_and_width():
2734763
@@ -144,7 +146,7 @@ def on_color(num):
70a8475
 
70a8475
     # Avoid testing red, blue, yellow, and cyan, since they might someday
70a8475
     # change depending on terminal type.
70a8475
-    t = TestTerminal()
70a8475
+    t = TestTerminal(force_styling=True)
70a8475
     eq_(t.white, color(7))
70a8475
     eq_(t.green, color(2))  # Make sure it's different than white.
70a8475
     eq_(t.on_black, on_color(0))
2734763
@@ -250,7 +252,7 @@ def test_nice_formatting_errors():
70a8475
 def test_init_descriptor_always_initted():
70a8475
     """We should be able to get a height and width even on no-tty Terminals."""
70a8475
     t = Terminal(stream=StringIO())
70a8475
-    eq_(type(t.height), int)
70a8475
+    assert isinstance(t.height, int) or t.height is None
70a8475
 
70a8475
 
70a8475
 def test_force_styling_none():
70a8475
-- 
2734763
2.14.4
70a8475