enforce setupterm() as a singleton of ``kind``

emit a warning when a Terminal instance is instantiated with a different ``kind`` variable as previously used, explaining that only the terminal capabilities of the first instance will be used. As this cannot be worked around in Python (problem exists in _cursesmodule.c), we simply emit a warning.

Those who *really* need more than one terminal kind are going to have to perform terminal capabilities in subprocesses. Test cases are a great example of that, a pull request doing so will come later.

(Another example is my own esoteric project of a telnet server, serving different capabilities for different clients in different sub-processes each, by using the multiprocess module.)
reinstate erroneously removed blank line

sometimes you just don't see these things until they become pull requests :-)
print ' ' => print(' ')

Use python3-compatible print statements for those good folk using it, who would like to follow the examples, without editing the provided lines.
Implement as_subprocess decorator

This decorator executes the decorated function within a child process. The child process raises an exception for failed test cases, writing to (shared) stdout/err, which flows through to the controlling process. Otherwise the an exit status of 0 is emitted.

The parent process, on the other hand, waits for the exit signal of the child, and asserts that the exit code is 0, causing a test case to fail if otherwise.
as_subprocess use pty.fork() instead of os.fork()

By using pty.fork(), we can remove the race condition of tty output clobbering about at random places in the screen, and assert that no output should ever be written by the child.

Child now cleanly write the traceback, followed by a '-='*20 separator, followed by the exception.

The parent now asserts that there should not be any child process output, clearly delimitating the start and end of such output by '='*40 seperator.
Wrap TestTerminal() instances with as_subprocess()

Tests that call Terminal() (currently, all of them), must be wrapped in a child process: a single call to setupterm() remains for the remainder of the session. Several test cases currently fail that previously passed. Subsequent commits will resolve those issues within blessings itself, or, where appropriate, the test cases.
resolve "must call setupterm() first" test failure

Previously, test cases for .number_of_colors always succeeded and returned value 256, regardless of wether the active terminal is force_styling=None, because a previously instantiated Terminal() would call setup term.

With the previously committed as_subprocess() wrappers, the test case "number_of_colors should return 0 when there's no tty." would fail with the error: "must call (at least) setupterm() first" (thrown by Modules/_cursesmodule.c).
resolve number_of_colors tests

Split TestTerminal() instances to separate child processes.
The Hypothesis is now well understood, comment removed.
The assertion that force_styling=True allows a 256-color terminal is now correct.
explicitly force_styling as None

only helps in review of test cases: the reader is assured that the following calls most certainly have a "does_styling" property of False.
colors: NullCallableString for does_styling=False

Calls for color() and on_color(), where does_styling is False, were calling tparm() anyway, raising "setupterm() must first be called" errors, which are silently(!) caught by ParametrizingString.__call__, returning u"", causing the test cases for test_null_callable_numeric_colors to fail with exception: "TypeError: 'unicode' object is not callable", for a call such as t.color(5)('smoo'). The first return value, t.color(5) returned a simple unicode u'', making the 2nd call ('smoo') not possible.
Resolve TypeError for NullCallableString

"Turtles all the way down": Even with the prior fix, explicitly making return values NullCallableString instead of silently-caught-tparm-exceptions, the exact same error is thrown: the return value of u'' was still returned by __call__.

So the same issue is resolved within NullCallableString: for a call such as t.color(5)('smoo'). The first return value, t.color(5) returned a simple unicode u'', making the 2nd call ('smoo') not possible.

This commit resolves the issue by returning yet 1 additional NullCallableString() instance.
hardcode TIOCGWINSZE for platforms missing it

according to the pexpect project i've been working with lately, there are many platforms that are missing this value from the termios module, but work perfectly fine with the hardcoded value supplied here. I believe Cygwin is such an environment.
Remove comment about tigetnum; it is wrong

at least in the sense, that calling setupterm() again has no effect.
Fallback to LINES and COLUMNS environment values

1. Provide the description of all 4 values returned by TIOCGWINSZ, hopefully removing the "magic numbers" away from [0:2], previously used. The second pair is actually meant to be the number of pixels -- though, in practice, as this is returned by a terminal driver in the kernel, it is usually wrong.

It may work, say, for a classic bsd/linux i386 vga bios console, but I'd be *very* surprised to see the kernel answer this correctly on behalf of whatever arbitrary window size was chosen by urxvt or Terminal.app.

2. Note that if a value that cannot be converted to an integer is stored in the LINES or COLUMNS environment variables, a ValueError exception is thrown. We let this raise and error out, as it is a very dubious thing to do!
Test _height_and_width using pty.fork()

We can actually assert that the values returned by _height_and_width() are correct by creating a pseudo-tty pair. The child process sets its own window size using the TIOCSWINSZ before it retrieves it via the TIOCGWINSZ ioctl used in the _height_and_width method.

(note: TIOCSWINSZ and TIOCGWINSZ appear almost identical
           ^-- index 5: G for get, S for set.
remove erroneously commited conflict line
resolve TypeError: isinstance() arg 2 must be ...

a class, type, or tuple of classes and types
fix test case: height_and_width

1. rename function to indicate that it only tests the return values
2. swap the arguments to isinstance(), so that the test case works :-)
test NullCallableString more closely

I believe once this is executed in a sub-process, it may actually fail, but I could be wrong.

Regardless, test more variations, and force_styling to None to more guarantee setupterm() has not been called first, though in this branch, it has been anyway and we can't really help that.
print ' ' => print(' ')

Use python3-compatible print statements for those good folk using it, who would like to follow the examples, without editing the provided lines.