blessings
blessings copied to clipboard
test suite fails when run without a tty
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)
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.
At least the 2nd crash is probably fixed by #31.
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
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.
closed by pull request #48
(Going through old issues here, looking at what's going on with them) This is still broken, it appears. Presumably because #49 never landed.
resolved by branch 'blessed-integration'
That patched tests.py uses nose
which should not be used with python 3.x https://nose.readthedocs.io/en/latest/