Commits

Anonymous committed fca0165

Replace my complex tests for urllib.* stuff with some simple tests based
on test_move_items

Comments (0)

Files changed (7)

         raise
 
 
+@py.test.mark.parametrize("item_name",
+                          [item.name for item in six._urllib_parse_moved_attributes])
+def test_move_items_urllib_parse(item_name):
+    """Ensure that everything loads correctly."""
+    getattr(six.moves.urllib.parse, item_name)
+
+
+@py.test.mark.parametrize("item_name",
+                          [item.name for item in six._urllib_error_moved_attributes])
+def test_move_items_urllib_error(item_name):
+    """Ensure that everything loads correctly."""
+    getattr(six.moves.urllib.error, item_name)
+
+
+@py.test.mark.parametrize("item_name",
+                          [item.name for item in six._urllib_request_moved_attributes])
+def test_move_items_urllib_request(item_name):
+    """Ensure that everything loads correctly."""
+    getattr(six.moves.urllib.request, item_name)
+
+
+@py.test.mark.parametrize("item_name",
+                          [item.name for item in six._urllib_response_moved_attributes])
+def test_move_items_urllib_response(item_name):
+    """Ensure that everything loads correctly."""
+    getattr(six.moves.urllib.response, item_name)
+
+
+@py.test.mark.parametrize("item_name",
+                          [item.name for item in six._urllib_robotparser_moved_attributes])
+def test_move_items_urllib_robotparser(item_name):
+    """Ensure that everything loads correctly."""
+    getattr(six.moves.urllib.robotparser, item_name)
+
+
 def test_filter():
     from six.moves import filter
     f = filter(lambda x: x % 2, range(10))

test_urllib_dot_error.py

-from six import PY3
-
-
-def test_import_urllib():
-    import six.moves.urllib
-
-
-def test_import_urllib_dot_error():
-    import six.moves.urllib.error
-
-
-def test_urllib_dot_error_URLError():
-    import six.moves.urllib.error
-
-    if PY3:
-        from urllib.error import URLError
-    else:
-        from urllib2 import URLError
-
-    assert six.moves.urllib.error.URLError == URLError
-
-
-def test_urllib_dot_error_HTTPError():
-    import six.moves.urllib.error
-
-    if PY3:
-        from urllib.error import HTTPError
-    else:
-        from urllib2 import HTTPError
-
-    assert six.moves.urllib.error.HTTPError == HTTPError
-
-
-def test_urllib_dot_error_ContentTooShortError():
-    import six.moves.urllib.error
-
-    if PY3:
-        from urllib.error import ContentTooShortError
-    else:
-        from urllib import ContentTooShortError
-
-    assert six.moves.urllib.error.ContentTooShortError == ContentTooShortError

test_urllib_dot_parse.py

-from six import PY3
-from six.moves import urllib
-
-
-def test_import_urllib():
-    import six.moves.urllib
-
-
-def test_import_urllib_dot_parse():
-    import six.moves.urllib.parse
-
-
-def test_urllib_parse_ParseResult():
-    if PY3:
-        from urllib.parse import ParseResult
-    else:
-        from urlparse import ParseResult
-
-    assert urllib.parse.ParseResult == ParseResult
-
-
-def test_urllib_parse_parse_qs():
-    if PY3:
-        from urllib.parse import parse_qs
-    else:
-        try:
-            from urlparse import parse_qs
-        except ImportError:
-            # This name isn't present in Python 2.5
-            return
-
-    arg = 'a=1&b=2'
-    assert urllib.parse.parse_qs(arg) == parse_qs(arg)
-
-
-def test_urllib_parse_parse_qsl():
-    if PY3:
-        from urllib.parse import parse_qsl
-    else:
-        try:
-            from urlparse import parse_qsl
-        except ImportError:
-            # This name isn't present in Python 2.5
-            return
-
-    arg = 'a=1&b=2'
-    assert urllib.parse.parse_qsl(arg) == parse_qsl(arg)
-
-
-def test_urllib_parse_quote():
-    if PY3:
-        from urllib.parse import quote
-    else:
-        from urllib import quote
-
-    arg = 'This is some text; a < b and b < c => a < c'
-    assert urllib.parse.quote(arg) == quote(arg)
-
-
-def test_urllib_parse_quote_plus():
-    if PY3:
-        from urllib.parse import quote_plus
-    else:
-        from urllib import quote_plus
-
-    arg = 'This is some text; a < b and b < c => a < c'
-    assert urllib.parse.quote_plus(arg) == quote_plus(arg)
-
-
-def test_urllib_defrag_urldefrag():
-    if PY3:
-        from urllib.parse import urldefrag
-    else:
-        from urlparse import urldefrag
-
-    url = 'http://mycompany.com/path/to/resource/?a=1&b=2'
-    assert urllib.parse.urldefrag(url) == urldefrag(url)
-
-
-def test_urllib_parse_urlencode():
-    if PY3:
-        from urllib.parse import urlencode
-    else:
-        from urllib import urlencode
-
-    arg = {'a': 1, 'b': 2}
-    assert urllib.parse.urlencode(arg) == urlencode(arg)
-
-
-def test_urllib_parse_urljoin():
-    if PY3:
-        from urllib.parse import urljoin
-    else:
-        from urlparse import urljoin
-
-    args = ('http://www.cwi.nl/%7Eguido/Python.html', 'FAQ.html')
-    assert urllib.parse.urljoin(*args) == urljoin(*args)
-
-
-def test_urllib_parse_urlparse():
-    if PY3:
-        from urllib.parse import urlparse
-    else:
-        from urlparse import urlparse
-
-    url = 'http://mycompany.com/path/to/resource/?a=1&b=2'
-    assert urllib.parse.urlparse(url) == urlparse(url)
-
-
-def test_urllib_split_urlsplit():
-    if PY3:
-        from urllib.parse import urlsplit
-    else:
-        from urlparse import urlsplit
-
-    url = 'http://mycompany.com/path/to/resource/?a=1&b=2'
-    assert urllib.parse.urlsplit(url) == urlsplit(url)
-
-
-def test_urllib_parse_urlunparse():
-    if PY3:
-        from urllib.parse import urlparse, urlunparse
-    else:
-        from urlparse import urlparse, urlunparse
-
-    url = 'http://mycompany.com/path/to/resource/?a=1&b=2'
-    assert urllib.parse.urlunparse(urlparse(url)) == urlunparse(urlparse(url))
-
-
-def test_urllib_parse_unquote():
-    if PY3:
-        from urllib.parse import quote, unquote
-    else:
-        from urllib import quote, unquote
-
-    arg = 'This is some text; a < b and b < c => a < c'
-    assert urllib.parse.unquote(quote(arg)) == unquote(quote(arg))
-
-
-def test_urllib_parse_unquote_plus():
-    if PY3:
-        from urllib.parse import quote, unquote_plus
-    else:
-        from urllib import quote, unquote_plus
-
-    arg = 'This is some text; a < b and b < c => a < c'
-    assert urllib.parse.unquote_plus(quote(arg)) == unquote_plus(quote(arg))
-
-
-def test_urllib_parse_urlunsplit():
-    if PY3:
-        from urllib.parse import urlsplit, urlunsplit
-    else:
-        from urlparse import urlsplit, urlunsplit
-
-    url = 'http://mycompany.com/path/to/resource/?a=1&b=2'
-    assert urllib.parse.urlunsplit(urlsplit(url)) == urlunsplit(urlsplit(url))
-
-

test_urllib_dot_request.py

-from six import PY3
-
-
-def test_import_urllib():
-    import six.moves.urllib
-
-
-def test_import_urllib_dot_request():
-    import six.moves.urllib.request
-
-
-def test_urllib_dot_request_urlopen():
-    import six.moves.urllib.request
-
-    if PY3:
-        from urllib.request import urlopen
-    else:
-        from urllib2 import urlopen
-
-    assert six.moves.urllib.request.urlopen == urlopen
-
-
-def test_urllib_dot_request_install_opener():
-    import six.moves.urllib.request
-
-    if PY3:
-        from urllib.request import install_opener
-    else:
-        from urllib2 import install_opener
-
-    assert six.moves.urllib.request.install_opener == install_opener
-
-
-def test_urllib_dot_request_build_opener():
-    import six.moves.urllib.request
-
-    if PY3:
-        from urllib.request import build_opener
-    else:
-        from urllib2 import build_opener
-
-    assert six.moves.urllib.request.build_opener == build_opener
-
-
-def test_urllib_dot_request_pathname2url():
-    import six.moves.urllib.request
-
-    if PY3:
-        from urllib.request import pathname2url
-    else:
-        from urllib import pathname2url
-
-    assert six.moves.urllib.request.pathname2url == pathname2url
-
-
-def test_urllib_dot_request_url2pathname():
-    import six.moves.urllib.request
-
-    if PY3:
-        from urllib.request import url2pathname
-    else:
-        from urllib import url2pathname
-
-    assert six.moves.urllib.request.url2pathname == url2pathname
-
-
-def test_urllib_dot_request_getproxies():
-    import six.moves.urllib.request
-
-    if PY3:
-        from urllib.request import getproxies
-    else:
-        from urllib import getproxies
-
-    assert six.moves.urllib.request.getproxies == getproxies
-
-
-def test_urllib_dot_request_Request():
-    import six.moves.urllib.request
-
-    if PY3:
-        from urllib.request import Request
-    else:
-        from urllib2 import Request
-
-    assert six.moves.urllib.request.Request == Request
-
-
-def test_urllib_dot_request_OpenerDirector():
-    import six.moves.urllib.request
-
-    if PY3:
-        from urllib.request import OpenerDirector
-    else:
-        from urllib2 import OpenerDirector
-
-    assert six.moves.urllib.request.OpenerDirector == OpenerDirector
-
-
-def test_urllib_dot_request_BaseHandler():
-    import six.moves.urllib.request
-
-    if PY3:
-        from urllib.request import BaseHandler
-    else:
-        from urllib2 import BaseHandler
-
-    assert six.moves.urllib.request.BaseHandler == BaseHandler
-
-
-def test_urllib_dot_request_HTTPDefaultErrorHandler():
-    import six.moves.urllib.request
-
-    if PY3:
-        from urllib.request import HTTPDefaultErrorHandler
-    else:
-        from urllib2 import HTTPDefaultErrorHandler
-
-    assert six.moves.urllib.request.HTTPDefaultErrorHandler == HTTPDefaultErrorHandler
-
-
-def test_urllib_dot_request_HTTPRedirectHandler():
-    import six.moves.urllib.request
-
-    if PY3:
-        from urllib.request import HTTPRedirectHandler
-    else:
-        from urllib2 import HTTPRedirectHandler
-
-    assert six.moves.urllib.request.HTTPRedirectHandler == HTTPRedirectHandler
-
-
-def test_urllib_dot_request_HTTPCookieProcessor():
-    import six.moves.urllib.request
-
-    if PY3:
-        from urllib.request import HTTPCookieProcessor
-    else:
-        from urllib2 import HTTPCookieProcessor
-
-    assert six.moves.urllib.request.HTTPCookieProcessor == HTTPCookieProcessor
-
-
-def test_urllib_dot_request_ProxyHandler():
-    import six.moves.urllib.request
-
-    if PY3:
-        from urllib.request import ProxyHandler
-    else:
-        from urllib2 import ProxyHandler
-
-    assert six.moves.urllib.request.ProxyHandler == ProxyHandler
-
-
-def test_urllib_dot_request_HTTPPasswordMgr():
-    import six.moves.urllib.request
-
-    if PY3:
-        from urllib.request import HTTPPasswordMgr
-    else:
-        from urllib2 import HTTPPasswordMgr
-
-    assert six.moves.urllib.request.HTTPPasswordMgr == HTTPPasswordMgr
-
-
-def test_urllib_dot_request_HTTPPasswordMgrWithDefaultRealm():
-    import six.moves.urllib.request
-
-    if PY3:
-        from urllib.request import HTTPPasswordMgrWithDefaultRealm
-    else:
-        from urllib2 import HTTPPasswordMgrWithDefaultRealm
-
-    assert six.moves.urllib.request.HTTPPasswordMgrWithDefaultRealm == HTTPPasswordMgrWithDefaultRealm
-
-
-def test_urllib_dot_request_AbstractBasicAuthHandler():
-    import six.moves.urllib.request
-
-    if PY3:
-        from urllib.request import AbstractBasicAuthHandler
-    else:
-        from urllib2 import AbstractBasicAuthHandler
-
-    assert six.moves.urllib.request.AbstractBasicAuthHandler == AbstractBasicAuthHandler
-
-
-def test_urllib_dot_request_HTTPBasicAuthHandler():
-    import six.moves.urllib.request
-
-    if PY3:
-        from urllib.request import HTTPBasicAuthHandler
-    else:
-        from urllib2 import HTTPBasicAuthHandler
-
-    assert six.moves.urllib.request.HTTPBasicAuthHandler == HTTPBasicAuthHandler
-
-
-def test_urllib_dot_request_ProxyBasicAuthHandler():
-    import six.moves.urllib.request
-
-    if PY3:
-        from urllib.request import ProxyBasicAuthHandler
-    else:
-        from urllib2 import ProxyBasicAuthHandler
-
-    assert six.moves.urllib.request.ProxyBasicAuthHandler == ProxyBasicAuthHandler
-
-
-def test_urllib_dot_request_AbstractDigestAuthHandler():
-    import six.moves.urllib.request
-
-    if PY3:
-        from urllib.request import AbstractDigestAuthHandler
-    else:
-        from urllib2 import AbstractDigestAuthHandler
-
-    assert six.moves.urllib.request.AbstractDigestAuthHandler == AbstractDigestAuthHandler
-
-
-def test_urllib_dot_request_HTTPDigestAuthHandler():
-    import six.moves.urllib.request
-
-    if PY3:
-        from urllib.request import HTTPDigestAuthHandler
-    else:
-        from urllib2 import HTTPDigestAuthHandler
-
-    assert six.moves.urllib.request.HTTPDigestAuthHandler == HTTPDigestAuthHandler
-
-
-def test_urllib_dot_request_ProxyDigestAuthHandler():
-    import six.moves.urllib.request
-
-    if PY3:
-        from urllib.request import ProxyDigestAuthHandler
-    else:
-        from urllib2 import ProxyDigestAuthHandler
-
-    assert six.moves.urllib.request.ProxyDigestAuthHandler == ProxyDigestAuthHandler
-
-
-def test_urllib_dot_request_HTTPHandler():
-    import six.moves.urllib.request
-
-    if PY3:
-        from urllib.request import HTTPHandler
-    else:
-        from urllib2 import HTTPHandler
-
-    assert six.moves.urllib.request.HTTPHandler == HTTPHandler
-
-
-def test_urllib_dot_request_HTTPSHandler():
-    import six.moves.urllib.request
-
-    if PY3:
-        from urllib.request import HTTPSHandler
-    else:
-        from urllib2 import HTTPSHandler
-
-    assert six.moves.urllib.request.HTTPSHandler == HTTPSHandler
-
-
-def test_urllib_dot_request_HTTPSHandler():
-    import six.moves.urllib.request
-
-    if PY3:
-        from urllib.request import HTTPSHandler
-    else:
-        from urllib2 import HTTPSHandler
-
-    assert six.moves.urllib.request.HTTPSHandler == HTTPSHandler
-
-
-def test_urllib_dot_request_FileHandler():
-    import six.moves.urllib.request
-
-    if PY3:
-        from urllib.request import FileHandler
-    else:
-        from urllib2 import FileHandler
-
-    assert six.moves.urllib.request.FileHandler == FileHandler
-
-
-def test_urllib_dot_request_FTPHandler():
-    import six.moves.urllib.request
-
-    if PY3:
-        from urllib.request import FTPHandler
-    else:
-        from urllib2 import FTPHandler
-
-    assert six.moves.urllib.request.FTPHandler == FTPHandler
-
-
-def test_urllib_dot_request_CacheFTPHandler():
-    import six.moves.urllib.request
-
-    if PY3:
-        from urllib.request import CacheFTPHandler
-    else:
-        from urllib2 import CacheFTPHandler
-
-    assert six.moves.urllib.request.CacheFTPHandler == CacheFTPHandler
-
-
-def test_urllib_dot_request_UnknownHandler():
-    import six.moves.urllib.request
-
-    if PY3:
-        from urllib.request import UnknownHandler
-    else:
-        from urllib2 import UnknownHandler
-
-    assert six.moves.urllib.request.UnknownHandler == UnknownHandler
-
-
-def test_urllib_dot_request_HTTPErrorProcessor():
-    import six.moves.urllib.request
-
-    if PY3:
-        from urllib.request import HTTPErrorProcessor
-    else:
-        from urllib2 import HTTPErrorProcessor
-
-    assert six.moves.urllib.request.HTTPErrorProcessor == HTTPErrorProcessor
-
-
-def test_urllib_dot_request_urlretrieve():
-    import six.moves.urllib.request
-
-    if PY3:
-        from urllib.request import urlretrieve
-    else:
-        from urllib import urlretrieve
-
-    assert six.moves.urllib.request.urlretrieve == urlretrieve
-
-
-def test_urllib_dot_request_urlcleanup():
-    import six.moves.urllib.request
-
-    if PY3:
-        from urllib.request import urlcleanup
-    else:
-        from urllib import urlcleanup
-
-    assert six.moves.urllib.request.urlcleanup == urlcleanup
-
-
-def test_urllib_dot_request_URLopener():
-    import six.moves.urllib.request
-
-    if PY3:
-        from urllib.request import URLopener
-    else:
-        from urllib import URLopener
-
-    assert six.moves.urllib.request.URLopener == URLopener
-
-
-def test_urllib_dot_request_FancyURLopener():
-    import six.moves.urllib.request
-
-    if PY3:
-        from urllib.request import FancyURLopener
-    else:
-        from urllib import FancyURLopener
-
-    assert six.moves.urllib.request.FancyURLopener == FancyURLopener

test_urllib_dot_response.py

-from six import PY3
-
-
-def test_import_urllib():
-    import six.moves.urllib
-
-
-def test_import_urllib_dot_response():
-    import six.moves.urllib.response
-
-
-def test_urllib_dot_response_addbase():
-    import six.moves.urllib.response
-
-    if PY3:
-        from urllib.response import addbase
-    else:
-        from urllib import addbase
-
-    assert six.moves.urllib.response.addbase == addbase
-
-
-def test_urllib_dot_response_addclosehook():
-    import six.moves.urllib.response
-
-    if PY3:
-        from urllib.response import addclosehook
-    else:
-        from urllib import addclosehook
-
-    assert six.moves.urllib.response.addclosehook == addclosehook
-
-
-def test_urllib_dot_response_addinfo():
-    import six.moves.urllib.response
-
-    if PY3:
-        from urllib.response import addinfo
-    else:
-        from urllib import addinfo
-
-    assert six.moves.urllib.response.addinfo == addinfo
-
-
-def test_urllib_dot_response_addinfourl():
-    import six.moves.urllib.response
-
-    if PY3:
-        from urllib.response import addinfourl
-    else:
-        from urllib import addinfourl
-
-    assert six.moves.urllib.response.addinfourl == addinfourl

test_urllib_dot_robotparser.py

-from six import PY3
-
-
-def test_import_urllib():
-    import six.moves.urllib
-
-
-def test_import_urllib_dot_robotparser():
-    import six.moves.urllib.robotparser
-
-
-def test_urllib_dot_robotparser_RobotFileParser():
-    import six.moves.urllib.robotparser
-
-    if PY3:
-        from urllib.robotparser import RobotFileParser
-    else:
-        from robotparser import RobotFileParser
-
-    assert six.moves.urllib.robotparser.RobotFileParser == RobotFileParser

test_urllib_parse.py

-from six import PY3
-from six.moves import urllib_parse
-
-
-def test_urllib_parse_parse_qs():
-    if PY3:
-        from urllib.parse import parse_qs
-    else:
-        try:
-            from urlparse import parse_qs
-        except ImportError:
-            # This name isn't present in Python 2.5
-            return
-
-    arg = 'a=1&b=2'
-    assert urllib_parse.parse_qs(arg) == parse_qs(arg)
-
-
-def test_urllib_parse_parse_qsl():
-    if PY3:
-        from urllib.parse import parse_qsl
-    else:
-        try:
-            from urlparse import parse_qsl
-        except ImportError:
-            # This name isn't present in Python 2.5
-            return
-
-    arg = 'a=1&b=2'
-    assert urllib_parse.parse_qsl(arg) == parse_qsl(arg)
-
-
-def test_urllib_parse_quote():
-    if PY3:
-        from urllib.parse import quote
-    else:
-        from urllib import quote
-
-    arg = 'This is some text; a < b and b < c => a < c'
-    assert urllib_parse.quote(arg) == quote(arg)
-
-
-def test_urllib_parse_quote_plus():
-    if PY3:
-        from urllib.parse import quote_plus
-    else:
-        from urllib import quote_plus
-
-    arg = 'This is some text; a < b and b < c => a < c'
-    assert urllib_parse.quote_plus(arg) == quote_plus(arg)
-
-
-def test_urllib_defrag_urldefrag():
-    if PY3:
-        from urllib.parse import urldefrag
-    else:
-        from urlparse import urldefrag
-
-    url = 'http://mycompany.com/path/to/resource/?a=1&b=2'
-    assert urllib_parse.urldefrag(url) == urldefrag(url)
-
-
-def test_urllib_parse_urlencode():
-    if PY3:
-        from urllib.parse import urlencode
-    else:
-        from urllib import urlencode
-
-    arg = {'a': 1, 'b': 2}
-    assert urllib_parse.urlencode(arg) == urlencode(arg)
-
-
-def test_urllib_parse_urljoin():
-    if PY3:
-        from urllib.parse import urljoin
-    else:
-        from urlparse import urljoin
-
-    args = ('http://www.cwi.nl/%7Eguido/Python.html', 'FAQ.html')
-    assert urllib_parse.urljoin(*args) == urljoin(*args)
-
-
-def test_urllib_parse_urlparse():
-    if PY3:
-        from urllib.parse import urlparse
-    else:
-        from urlparse import urlparse
-
-    url = 'http://mycompany.com/path/to/resource/?a=1&b=2'
-    assert urllib_parse.urlparse(url) == urlparse(url)
-
-
-def test_urllib_split_urlsplit():
-    if PY3:
-        from urllib.parse import urlsplit
-    else:
-        from urlparse import urlsplit
-
-    url = 'http://mycompany.com/path/to/resource/?a=1&b=2'
-    assert urllib_parse.urlsplit(url) == urlsplit(url)
-
-
-def test_urllib_parse_urlunparse():
-    if PY3:
-        from urllib.parse import urlparse, urlunparse
-    else:
-        from urlparse import urlparse, urlunparse
-
-    url = 'http://mycompany.com/path/to/resource/?a=1&b=2'
-    assert urllib_parse.urlunparse(urlparse(url)) == urlunparse(urlparse(url))
-
-
-def test_urllib_parse_unquote():
-    if PY3:
-        from urllib.parse import quote, unquote
-    else:
-        from urllib import quote, unquote
-
-    arg = 'This is some text; a < b and b < c => a < c'
-    assert urllib_parse.unquote(quote(arg)) == unquote(quote(arg))
-
-
-def test_urllib_parse_unquote_plus():
-    if PY3:
-        from urllib.parse import quote, unquote_plus
-    else:
-        from urllib import quote, unquote_plus
-
-    arg = 'This is some text; a < b and b < c => a < c'
-    assert urllib_parse.unquote_plus(quote(arg)) == unquote_plus(quote(arg))
-
-
-def test_urllib_split_urlunsplit():
-    if PY3:
-        from urllib.parse import urlsplit, urlunsplit
-    else:
-        from urlparse import urlsplit, urlunsplit
-
-    url = 'http://mycompany.com/path/to/resource/?a=1&b=2'
-    assert urllib_parse.urlunsplit(urlsplit(url)) == urlunsplit(urlsplit(url))
-
-
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.