Unit tests (CLI tests flake8 and Travis fix) (rebased onto dev_4_4)



This is the same as gh-1821 but rebased onto dev_4_4.

----

This PR fixes the unit tests (in preparation of https://trac.openmicroscopy.org.uk/ome/ticket/11201) by
- fixing the `flake8` output for all the CLI tests under `test/unit/clitest`
- refactoring `test_prefs.py` to use the pytest `capsys` fixture directly (see #1792)
- adding a commit which fixes `pytest` installation in the Travis environment so that the unit tests can be run
- add `cleanup()` methods to `test_hdfstorage.py` so that the Python build of Travis turns green again