summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Tate <joseph@crunch.io>2015-04-16 10:25:22 -0400
committerJoseph Tate <joseph@crunch.io>2015-04-20 03:02:58 -0400
commita41f4fb4d26995bcadfc26540ad84a84b0e10e0d (patch)
tree64c5f78d5b4411749c5d311700c115657124aebf
parent1be2f1cde1ee003d33f5445bb60642801ff7102b (diff)
downloadoauthlib-a41f4fb4d26995bcadfc26540ad84a84b0e10e0d.tar.gz
Add the broken scope to the ValueError exception for easier debugging, add test for failure case.
-rw-r--r--oauthlib/oauth2/rfc6749/utils.py2
-rw-r--r--tests/oauth2/rfc6749/test_utils.py2
2 files changed, 3 insertions, 1 deletions
diff --git a/oauthlib/oauth2/rfc6749/utils.py b/oauthlib/oauth2/rfc6749/utils.py
index 49c3a2f..870ac32 100644
--- a/oauthlib/oauth2/rfc6749/utils.py
+++ b/oauthlib/oauth2/rfc6749/utils.py
@@ -27,7 +27,7 @@ def list_to_scope(scope):
elif isinstance(scope, (set, tuple, list)):
return " ".join([unicode_type(s) for s in scope])
else:
- raise ValueError("Invalid scope, must be string or list.")
+ raise ValueError("Invalid scope (%s), must be string, tuple, set, or list." % scope)
def scope_to_list(scope):
diff --git a/tests/oauth2/rfc6749/test_utils.py b/tests/oauth2/rfc6749/test_utils.py
index 573b187..691de76 100644
--- a/tests/oauth2/rfc6749/test_utils.py
+++ b/tests/oauth2/rfc6749/test_utils.py
@@ -85,6 +85,8 @@ class UtilsTests(TestCase):
for x in string_list:
assert x in set_scope
+ self.assertRaises(ValueError, list_to_scope, object())
+
def test_scope_to_list(self):
expected = ['foo', 'bar', 'baz']