def test_urllib_imports_install_aliases(self): with standard_library.suspend_hooks(): standard_library.install_aliases() import urllib import urllib.parse import urllib.request import urllib.robotparser import urllib.error import urllib.response self.assertTrue(True)
def test_suspend_hooks(self): example_PY2_check = False with standard_library.suspend_hooks(): # An example of fragile import code that we don't want to break: try: import builtins except ImportError: example_PY2_check = True if utils.PY2: self.assertTrue(example_PY2_check) else: self.assertFalse(example_PY2_check) # The import should succeed again now: import builtins
def test_suspend_hooks(self): """ Code like the try/except block here appears in Pyflakes v0.6.1. This method tests whether suspend_hooks() works as advertised. """ example_PY2_check = False with standard_library.suspend_hooks(): # An example of fragile import code that we don't want to break: try: import builtins except ImportError: example_PY2_check = True if utils.PY2: self.assertTrue(example_PY2_check) else: self.assertFalse(example_PY2_check) # The import should succeed again now: import builtins
from __future__ import absolute_import from future.standard_library import suspend_hooks from future.utils import PY3 if PY3: from test.support import * else: __future_module__ = True with suspend_hooks(): from test.test_support import *
from __future__ import absolute_import from future.standard_library import suspend_hooks from future.utils import PY3 if PY3: from urllib.error import * else: __future_module__ = True # We use this method to get at the original Py2 urllib before any renaming magic # ContentTooShortError = sys.py2_modules['urllib'].ContentTooShortError with suspend_hooks(): from urllib import ContentTooShortError from urllib2 import URLError, HTTPError
from future import standard_library from future.utils import PY3 if PY3: pass else: __future_module__ = True with standard_library.suspend_hooks(): pass
from future import standard_library from future.utils import PY3 if PY3: from urllib.response import * else: __future_module__ = True with standard_library.suspend_hooks(): from urllib import (addbase, addclosehook, addinfo, addinfourl)