Commits

Marc Abramowitz committed 5701d14

Add test_urllib_parse.py which is useful for testing the six.moves.urllib_parse
functionality added in d49087c4cda8

  • Participants
  • Parent commits d49087c

Comments (0)

Files changed (1)

test_urllib_parse.py

+from six import PY3
+from six.moves import urllib_parse
+
+quote_msg = 'this is some text processed with quote'
+quote_plus_msg = 'this is some text processed with quote_plus'
+url = 'http://mycompany.com/path/to/resource/?a=1&b=2'
+
+print(urllib_parse.quote(quote_msg))
+print(urllib_parse.quote_plus(quote_plus_msg))
+print(urllib_parse.urlparse(url))
+
+if PY3:
+    import urllib.parse
+    assert urllib_parse.quote(quote_msg) == urllib.parse.quote(quote_msg)
+    assert urllib_parse.quote_plus(quote_plus_msg) == urllib.parse.quote_plus(quote_plus_msg)
+    assert urllib_parse.urlparse(url) == urllib.parse.urlparse(url)
+else:
+    import urllib, urlparse
+    assert urllib_parse.quote('this is some text') == urllib.quote('this is some text')
+    assert urllib_parse.quote_plus('this is some text') == urllib.quote_plus('this is some text')
+    assert urllib_parse.urlparse(url) == urlparse.urlparse(url)