Skip to content

Commit

Permalink
fix tests when run without a tty (fixes erikrose#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
danc86 committed Nov 30, 2012
1 parent b781239 commit ba9489d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion blessings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ def __new__(cls):
new = unicode.__new__(cls, u'')
return new

def __call__(self, arg):
def __call__(self, arg, *extra_args):
if isinstance(arg, int):
return u''
return arg # TODO: Force even strs in Python 2.x to be unicodes? Nah. How would I know what encoding to use to convert it?
Expand Down
8 changes: 5 additions & 3 deletions blessings/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def test_capability():
"""
t = TestTerminal()
if not t.is_a_tty:
raise SkipTest
sc = unicode_cap('sc')
eq_(t.save, sc)
eq_(t.save, sc) # Make sure caching doesn't screw it up.
Expand All @@ -64,7 +66,7 @@ def test_capability_with_forced_tty():

def test_parametrization():
"""Test parametrizing a capability."""
eq_(TestTerminal().cup(3, 4), unicode_parm('cup', 3, 4))
eq_(TestTerminal(force_styling=True).cup(3, 4), unicode_parm('cup', 3, 4))


def height_and_width():
Expand Down Expand Up @@ -143,7 +145,7 @@ def on_color(num):

# Avoid testing red, blue, yellow, and cyan, since they might someday
# change depending on terminal type.
t = TestTerminal()
t = TestTerminal(force_styling=True)
eq_(t.white, color(7))
eq_(t.green, color(2)) # Make sure it's different than white.
eq_(t.on_black, on_color(0))
Expand Down Expand Up @@ -247,7 +249,7 @@ def test_nice_formatting_errors():
def test_init_descriptor_always_initted():
"""We should be able to get a height and width even on no-tty Terminals."""
t = Terminal(stream=StringIO())
eq_(type(t.height), int)
assert isinstance(t.height, int) or t.height is None


def test_force_styling_none():
Expand Down

0 comments on commit ba9489d

Please sign in to comment.