Permalink
Browse files

urllib.unqoute doesn't take 'safe' as an arg. Add a test and fix.

  • Loading branch information...
1 parent 7118970 commit e569fc16ed65a2bfe50061a58f21579025eff3c3 @calebbrown committed Apr 18, 2012
Showing with 9 additions and 5 deletions.
  1. +1 −1 oauthlib/oauth1/rfc5849/utils.py
  2. +8 −4 tests/oauth1/rfc5849/test_utils.py
@@ -104,7 +104,7 @@ def escape(u):
def unescape(s):
if not isinstance(s, str):
raise ValueError('Only string objects are unescapable.')
- return urllib.unquote(s, safe='~').decode('utf-8')
+ return urllib.unquote(s).decode('utf-8')
def urlencode(query):
@@ -39,7 +39,7 @@ class UtilsTests(TestCase):
oauth_signature_method="HMAC-SHA1",
oauth_timestamp="137131201",
oauth_nonce="7d8f3e4a",
- oauth_signature="djosJKDKJSD8743243%2Fjdk33klY%3D" """.strip()
+ oauth_signature="djosJKDKJSD8743243%2Fjdk33klY%3D" """.strip()
def test_filter_params(self):
@@ -73,7 +73,7 @@ def test_filter_oauth_params(self):
# should not be present in the filtered params
filtered_params = filter_oauth_params(self.sample_params_list)
self.assertEqual(len(filtered_params), 2)
-
+
self.assertTrue(filtered_params[0][0].startswith('oauth'))
self.assertTrue(filtered_params[1][0].startswith('oauth'))
@@ -86,7 +86,7 @@ def test_filter_oauth_params(self):
# should not be present in the filtered params
filtered_params = filter_oauth_params(self.sample_params_dict)
self.assertEqual(len(filtered_params), 2)
-
+
self.assertTrue(filtered_params[0][0].startswith('oauth'))
self.assertTrue(filtered_params[1][0].startswith('oauth'))
@@ -95,7 +95,7 @@ def test_utf8_str(self):
# check against crazy string
crazy_string = "àçéghîłñôßûÿž♬♨♧"
self.assertTrue(isinstance(utf8_str(crazy_string), str))
-
+
# check against crazy unicode
crazy_unicode = utf8_str(u"àçéghîłñôßûÿž♬♨♧")
self.assertTrue(isinstance(crazy_unicode, str))
@@ -129,6 +129,10 @@ def test_escape(self):
self.assertRaises(ValueError, escape, "I am a string type. Not a unicode type.")
self.assertEqual(escape(u"I am a unicode type."), u"I%20am%20a%20unicode%20type.")
+ def test_unescape(self):
+ self.assertRaises(ValueError, unescape, u"I am a unicode type. Not a string type.")
+ self.assertEqual(unescape("I%20am%20a%20unicode%20type."), u'I am a unicode type.')
+
def test_urlencode(self):
self.assertEqual(urlencode(self.sample_params_unicode_list), "notoauth=shouldnotbehere&oauth_consumer_key=9djdj82h48djs9d2&oauth_token=kkk9d7dh3k39sjv7&notoautheither=shouldnotbehere")

0 comments on commit e569fc1

Please sign in to comment.