diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_urllib.py | 24 | ||||
-rw-r--r-- | Lib/test/test_urllibnet.py | 10 | ||||
-rw-r--r-- | Lib/urllib.py | 7 |
3 files changed, 27 insertions, 14 deletions
diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py index 61e0202a3e..1dcbbedd70 100644 --- a/Lib/test/test_urllib.py +++ b/Lib/test/test_urllib.py @@ -640,16 +640,20 @@ class Pathname_Tests(unittest.TestCase): def test_main(): - test_support.run_unittest( - urlopen_FileTests, - urlopen_HttpTests, - urlretrieve_FileTests, - QuotingTests, - UnquotingTests, - urlencode_Tests, - Pathname_Tests, - #FTPWrapperTests, - ) + import warnings + with test_support.catch_warning(record=False): + warnings.filterwarnings('ignore', ".*urllib\.urlopen.*Python 3.0", + DeprecationWarning) + test_support.run_unittest( + urlopen_FileTests, + urlopen_HttpTests, + urlretrieve_FileTests, + QuotingTests, + UnquotingTests, + urlencode_Tests, + Pathname_Tests, + #FTPWrapperTests, + ) diff --git a/Lib/test/test_urllibnet.py b/Lib/test/test_urllibnet.py index 5e225ee639..0404b77ac3 100644 --- a/Lib/test/test_urllibnet.py +++ b/Lib/test/test_urllibnet.py @@ -182,9 +182,13 @@ class urlretrieveNetworkTests(unittest.TestCase): def test_main(): test_support.requires('network') - test_support.run_unittest(URLTimeoutTest, - urlopenNetworkTests, - urlretrieveNetworkTests) + from warnings import filterwarnings + with test_support.catch_warning(record=False): + filterwarnings('ignore', '.*urllib\.urlopen.*Python 3.0', + DeprecationWarning) + test_support.run_unittest(URLTimeoutTest, + urlopenNetworkTests, + urlretrieveNetworkTests) if __name__ == "__main__": test_main() diff --git a/Lib/urllib.py b/Lib/urllib.py index ab22a958e4..55a29f4fc8 100644 --- a/Lib/urllib.py +++ b/Lib/urllib.py @@ -28,6 +28,7 @@ import os import time import sys from urlparse import urljoin as basejoin +import warnings __all__ = ["urlopen", "URLopener", "FancyURLopener", "urlretrieve", "urlcleanup", "quote", "quote_plus", "unquote", "unquote_plus", @@ -69,7 +70,11 @@ else: # Shortcut for basic usage _urlopener = None def urlopen(url, data=None, proxies=None): - """urlopen(url [, data]) -> open file-like object""" + """Create a file-like object for the specified URL to read from.""" + from warnings import warnpy3k + warnings.warnpy3k("urllib.urlopen() has been removed in Python 3.0 in " + "favor of urllib2.urlopen()", stacklevel=2) + global _urlopener if proxies is not None: opener = FancyURLopener(proxies=proxies) |