try/expect around logging.captureWarnings

It is only available on python 2.7+, and if
not available the 'py.warnings' logger will
be unused.