refactor out code duplication

pull out the duplication of setup that was in all the test
functions and put it in setup instead.

capture stdout/stderr on pretty tox tests

if something goes wrong in the pretty tox tests, we actually get
entirely unhelpful 1 != 0 errors, that provide no ability to
debug. A big part of this is because stdout and stderr were not
captured.

Capture and replay stdout / stderr in case of fails to be able to
debug.

Change-Id: I7c21e47805a765d9e3c8f367dfa153d54ff10414
Merge "refactor out code duplication"