erikrose/blessings — pull request #38 by jquast (2013-09-08 15:08:07+00:00)
Title: Issue #33; cannot call setupterm() more than once; emit warning

This large branch commit seperates the original "tests.py" into three individual files for the three different test cases. forced_styling without a tty, forced styling (presumably, but not always --) with a tty, and no styling, without a tty. TestTerminal is no longer a 'partial' re-instantiated at each function, it is a singleton for each test case file, and therefor process. For the StringIO-based tests, it is now necessary to truncate the StringIO buffer after each write.

This version also ensures height and width is retrievable, even when the init_descriptor and sys.__stdout__ is not a tty, which was not the case previously (test case failed when |cat was piped to test cases). This is achieved by falling back to LINES and COLUMNS, and finally, a default value of 80x24. A warning is emitted if the values of LINES or COLUMNS is not an integer.

These test cases now include additional tests for testing that warnings are emitted -- I am not able to discover a way to test that LINES/COLUMNS non-int is emitted; I think the direct use of sys.__stdout__ in _height_and_width prevents it, so this test raises SkipTest.

Some additional kinds of TypeError's for bad args to capabilities are tested.