Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test suite fails when run without a tty #25

Open
danc86 opened this issue Nov 30, 2012 · 8 comments
Open

test suite fails when run without a tty #25

danc86 opened this issue Nov 30, 2012 · 8 comments
Labels

Comments

@danc86
Copy link

danc86 commented Nov 30, 2012

If the tests are run with stdout redirected to something that isn't a tty (for example to a log file) there are some failures:

$ python setup.py test | cat
[...]

======================================================================
ERROR: blessings.tests.test_capability
Check that a capability lookup works.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/home/dcallagh/work/blessings/blessings/tests.py", line 47, in test_capability
    sc = unicode_cap('sc')
  File "/home/dcallagh/work/blessings/blessings/tests.py", line 31, in unicode_cap
    return tigetstr(cap).decode('utf-8')
error: must call (at least) setupterm() first

======================================================================
ERROR: blessings.tests.test_parametrization
Test parametrizing a capability.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/home/dcallagh/work/blessings/blessings/tests.py", line 67, in test_parametrization
    eq_(TestTerminal().cup(3, 4), unicode_parm('cup', 3, 4))
TypeError: __call__() takes exactly 2 arguments (3 given)

======================================================================
FAIL: blessings.tests.test_mnemonic_colors
Make sure color shortcuts work.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/home/dcallagh/work/blessings/blessings/tests.py", line 147, in test_mnemonic_colors
    eq_(t.white, color(7))
  File "/usr/lib/python2.7/site-packages/nose/tools.py", line 31, in eq_
    assert a == b, msg or "%r != %r" % (a, b)
AssertionError: u'' != u'\x1b[37m'

======================================================================
FAIL: blessings.tests.test_init_descriptor_always_initted
We should be able to get a height and width even on no-tty Terminals.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/home/dcallagh/work/blessings/blessings/tests.py", line 250, in test_init_descriptor_always_initted
    eq_(type(t.height), int)
  File "/usr/lib/python2.7/site-packages/nose/tools.py", line 31, in eq_
    assert a == b, msg or "%r != %r" % (a, b)
AssertionError: <type 'NoneType'> != <type 'int'>

----------------------------------------------------------------------
Ran 21 tests in 0.011s

FAILED (failures=2, errors=2, skipped=1)
danc86 added a commit to danc86/blessings that referenced this issue Nov 30, 2012
@erikrose
Copy link
Owner

I'll note that I've spent the better part of an afternoon trying to mock a real terminal—using subprocess and shell scripts and script and anything else I could muster—to the point where isatty returns true, all to no avail. So the only way to get the tests to pass like this would be to mock out Terminal.is_a_tty or something that leads to it.

@erikrose
Copy link
Owner

At least the 2nd crash is probably fixed by #31.

@jquast
Copy link
Collaborator

jquast commented Aug 30, 2013

I think you could get "isatty" to succeed if you used a pseudo-terminal. Perhaps i'll take a knock at this on the weekend

@jquast
Copy link
Collaborator

jquast commented Sep 25, 2013

I did knock it out, the as_subproces decorator proposed in the fix-tests branch ensures that stdout is always a tty, even when it isn't. these test cases now pass in that branch when piped to |cat, |tee, etc.

@jquast
Copy link
Collaborator

jquast commented Nov 5, 2013

closed by pull request #48

@fwenzel
Copy link
Collaborator

fwenzel commented Apr 29, 2014

(Going through old issues here, looking at what's going on with them) This is still broken, it appears. Presumably because #49 never landed.

@jquast
Copy link
Collaborator

jquast commented Apr 8, 2015

resolved by branch 'blessed-integration'

@kloczek
Copy link

kloczek commented Dec 30, 2021

That patched tests.py uses nose which should not be used with python 3.x https://nose.readthedocs.io/en/latest/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants