In fact, re-importing sys inside a conditional causes an UnboundLocalError, which is making the tests fail on Travis.