bpython / curtsies

Curses-like terminal wrapper with a display based on compositing 2d arrays of text.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Do not run some tests if not run with a TTY

sebastinas opened this issue · comments

Forwarding a bug report from Debian (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=806480). Looks like some tests fail with closed stdin and if stdout is redirected to a file. Could this tests be protected with some kind of check?

If this produced the same environment,

import sys
import nose

if __name__ == '__main__':
    sys.stdin.close()
    sys.stdout.close()
    nose.run()

then thomasballinger@5384f45 should fix it.

This is in a released version now because I needed to release for the FtmStr equality bug FYI

I see the failing test with version 0.2.4 and this patch.

Ah rats. I assume 0.1.21 is failing in the same way? That's the one I was trying to fix, but I assume results would be the same with 0.2.4 and the patch applied.

@jlec or @sebastinas, could you point me to how to run these tests in this way? Or happen to know how to mimic whatever aspect of these conditions is causing the failures?

It seems the tests are run with something like nosetests </dev/null. That's enough to reproduce the problem in the 0.1.x branch.

In Gentoo we are running python setup.py build, set PYTHONPATH to the newly build files, and run nosetests --verbose tests.

Doing a sys.stdin.isatty check now, was silly of me to assume that stdin would be closed at the Python level. Fixed in both 0.1.x and master, no releases yet.

This has been released as curtsies-0.1.22, and curtsies-0.2.5

For both versions I see

======================================================================
ERROR: test_array_from_text (test_window.TestBaseWindow)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/var/tmp/portage/dev-python/curtsies-0.2.5/work/curtsies-0.2.5/tests/test_window.py", line 42, in test_array_from_text
    a = window.array_from_text('.\n.\n.')
  File "/var/tmp/portage/dev-python/curtsies-0.2.5/work/curtsies-0.2.5-python2_7/lib/curtsies/window.py", line 79, in array_from_text
    return self.array_from_text_rc(msg, rows, columns)
  File "/var/tmp/portage/dev-python/curtsies-0.2.5/work/curtsies-0.2.5-python2_7/lib/curtsies/window.py", line 86, in array_from_text_rc
    if i >= rows * columns:
TypeError: unsupported operand type(s) for *: 'NoneType' and 'NoneType'
-------------------- >> begin captured logging << --------------------
curtsies.window: DEBUG: -------initializing Window object <curtsies.window.BaseWindow object at 0x7fd3f29ad190>------

@jlec There's now a 0.1.23 and a 0.2.6, is it fixed in these?

There's now a 0.1.23 and a 0.2.6, is it fixed in these?
Works perfectly.