From a9deb08f529cff605b2fb8ab5106832ad06cb9d7 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Fri, 4 Jan 2013 11:58:42 -0500 Subject: Fix a typo in the code that converts arguments from bytes to unicodes. --- oauthlib/oauth1/rfc5849/__init__.py | 4 ++-- tests/oauth1/rfc5849/test_client.py | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/oauthlib/oauth1/rfc5849/__init__.py b/oauthlib/oauth1/rfc5849/__init__.py index f3dcd22..fed413d 100644 --- a/oauthlib/oauth1/rfc5849/__init__.py +++ b/oauthlib/oauth1/rfc5849/__init__.py @@ -54,8 +54,8 @@ class Client(object): client_key = client_key.decode(encoding) if isinstance(client_secret, bytes_type): client_secret = client_secret.decode(encoding) - if isinstance(resource_owner, bytes_type): - resource_owner = resource_owner.decode(encoding) + if isinstance(resource_owner_key, bytes_type): + resource_owner_key = resource_owner_key.decode(encoding) if isinstance(resource_owner_secret, bytes_type): resource_owner_secret = resource_owner_secret.decode(encoding) if isinstance(callback_uri, bytes_type): diff --git a/tests/oauth1/rfc5849/test_client.py b/tests/oauth1/rfc5849/test_client.py index 5cc1f7e..c2b877e 100644 --- a/tests/oauth1/rfc5849/test_client.py +++ b/tests/oauth1/rfc5849/test_client.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, unicode_literals -from oauthlib.oauth1.rfc5849 import Client +from oauthlib.oauth1.rfc5849 import Client, bytes_type from ...unittest import TestCase @@ -27,3 +27,13 @@ class ClientRealmTests(TestCase): header["Authorization"].startswith('OAuth realm="baa-realm",')) # make sure sign() does not override the default realm self.assertEqual(client.realm, "moo-realm") + + +class ClientConstructorTests(TestCase): + + def test_convert_to_unicode_resource_owner(self): + client = Client('client-key', + resource_owner_key=b'owner key', + convert_to_unicode=True) + self.assertFalse(isinstance(client.resource_owner_key, bytes_type)) + self.assertEqual(client.resource_owner_key, 'owner key') -- cgit v1.2.1