tests: add an environment variable to disable network tests

This is useful when we want to test the package on an environement
without networking. This can happen on some buildbots, like the Debian
builders.
Fix @unittest.skipIf error on Python 2.6.