TST: proper handling of warning, requires python >= 2.6