from __future__ import absolute_import, print_function

import sys
from future.tests.base import unittest

class ImportUrllibTest(unittest.TestCase):
    def test_urllib(self):
        """
        Tests that urllib isn't changed from under our feet. (This might not
        even be a problem?)
        """
        from future import standard_library
        import urllib
        orig_file = urllib.__file__
        with standard_library.hooks():
            import urllib.response
        self.assertEqual(orig_file, urllib.__file__)


if __name__ == '__main__':
    unittest.main()

@@ -99,16 +99,69 @@
 nittest%0A
+from future.standard_library import install_aliases%0A%0A
 %0Aclass I
@@ -582,16 +582,788 @@
 ile__)%0A%0A
+    def test_issue_158(self):%0A        %22%22%22%0A        CherryPy conditional import in _cpcompat.py: issue 158%0A        %22%22%22%0A        install_aliases()%0A        try:%0A            from urllib.parse import unquote as parse_unquote%0A%0A            def unquote_qs(atom, encoding, errors='strict'):%0A                return parse_unquote(%0A                    atom.replace('+', ' '),%0A                    encoding=encoding,%0A                    errors=errors)%0A        except ImportError:%0A            from urllib import unquote as parse_unquote%0A%0A            def unquote_qs(atom, encoding, errors='strict'):%0A                return parse_unquote(atom.replace('+', ' ')).decode(encoding, errors)%0A        self.assertEqual(unquote_qs('/%257Econnolly/', 'utf-8'),%0A                         '/~connolly/')%0A%0A
 %0Aif __na

Add test that highlights issue #158