Fix ResourceWarnings under Python 3
Avoid deprecated assertion methods