Use six.text_type instead of unicode().
I will be switch to use ``from __future__ import unicode_literals`` later.
This commit is contained in:
@@ -18,6 +18,8 @@
|
||||
import pkg_resources
|
||||
import pytest
|
||||
|
||||
import six
|
||||
|
||||
import six.moves.urllib.parse as urlparse
|
||||
|
||||
from mediagoblin import mg_globals
|
||||
@@ -109,7 +111,7 @@ def test_register_views(test_app):
|
||||
## Make sure user is logged in
|
||||
request = template.TEMPLATE_TEST_CONTEXT[
|
||||
'mediagoblin/user_pages/user_nonactive.html']['request']
|
||||
assert request.session['user_id'] == unicode(new_user.id)
|
||||
assert request.session['user_id'] == six.text_type(new_user.id)
|
||||
|
||||
## Make sure we get email confirmation, and try verifying
|
||||
assert len(mail.EMAIL_TEST_INBOX) == 1
|
||||
@@ -307,7 +309,7 @@ def test_authentication_views(test_app):
|
||||
# Make sure user is in the session
|
||||
context = template.TEMPLATE_TEST_CONTEXT['mediagoblin/root.html']
|
||||
session = context['request'].session
|
||||
assert session['user_id'] == unicode(test_user.id)
|
||||
assert session['user_id'] == six.text_type(test_user.id)
|
||||
|
||||
# Successful logout
|
||||
# -----------------
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
import json
|
||||
|
||||
import pytest
|
||||
import six
|
||||
|
||||
from urlparse import urlparse, parse_qs
|
||||
|
||||
from mediagoblin import mg_globals
|
||||
@@ -63,7 +65,7 @@ class TestHTTPCallback(object):
|
||||
code = parse_qs(urlparse(redirect.location).query)['code'][0]
|
||||
|
||||
client = self.db.OAuthClient.query.filter(
|
||||
self.db.OAuthClient.identifier == unicode(client_id)).first()
|
||||
self.db.OAuthClient.identifier == six.text_type(client_id)).first()
|
||||
|
||||
client_secret = client.secret
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
import pkg_resources
|
||||
import pytest
|
||||
import mock
|
||||
import six
|
||||
|
||||
import six.moves.urllib.parse as urlparse
|
||||
|
||||
@@ -122,6 +123,6 @@ def test_ldap_plugin(ldap_plugin_app):
|
||||
# Make sure user is in the session
|
||||
context = template.TEMPLATE_TEST_CONTEXT['mediagoblin/root.html']
|
||||
session = context['request'].session
|
||||
assert session['user_id'] == unicode(test_user.id)
|
||||
assert session['user_id'] == six.text_type(test_user.id)
|
||||
|
||||
_test_authentication()
|
||||
|
||||
@@ -18,6 +18,8 @@ import json
|
||||
import logging
|
||||
|
||||
import pytest
|
||||
import six
|
||||
|
||||
from urlparse import parse_qs, urlparse
|
||||
|
||||
from mediagoblin import mg_globals
|
||||
@@ -154,7 +156,7 @@ class TestOAuth(object):
|
||||
code = self.get_code_from_redirect_uri(code_redirect.location)
|
||||
|
||||
client = self.db.OAuthClient.query.filter(
|
||||
self.db.OAuthClient.identifier == unicode(client_id)).first()
|
||||
self.db.OAuthClient.identifier == six.text_type(client_id)).first()
|
||||
|
||||
token_res = self.test_app.get('/oauth-2/access_token?client_id={0}&\
|
||||
code={1}&client_secret={2}'.format(client_id, code, client.secret))
|
||||
@@ -182,7 +184,7 @@ code={1}&client_secret={2}'.format(client_id, code, client.secret))
|
||||
code = self.get_code_from_redirect_uri(code_redirect.location)
|
||||
|
||||
client = self.db.OAuthClient.query.filter(
|
||||
self.db.OAuthClient.identifier == unicode(client_id)).first()
|
||||
self.db.OAuthClient.identifier == six.text_type(client_id)).first()
|
||||
|
||||
token_res = self.test_app.get('/oauth-2/access_token?\
|
||||
code={0}&client_secret={1}'.format(code, client.secret))
|
||||
|
||||
@@ -18,6 +18,7 @@ import urlparse
|
||||
import pkg_resources
|
||||
import pytest
|
||||
import mock
|
||||
import six
|
||||
|
||||
openid_consumer = pytest.importorskip(
|
||||
"openid.consumer.consumer")
|
||||
@@ -206,7 +207,7 @@ class TestOpenIDPlugin(object):
|
||||
# Make sure user is in the session
|
||||
context = template.TEMPLATE_TEST_CONTEXT['mediagoblin/root.html']
|
||||
session = context['request'].session
|
||||
assert session['user_id'] == unicode(test_user.id)
|
||||
assert session['user_id'] == six.text_type(test_user.id)
|
||||
|
||||
_test_new_user()
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
import pkg_resources
|
||||
import pytest
|
||||
import mock
|
||||
import six
|
||||
|
||||
import six.moves.urllib.parse as urlparse
|
||||
|
||||
@@ -142,7 +143,7 @@ class TestPersonaPlugin(object):
|
||||
# Make sure user is in the session
|
||||
context = template.TEMPLATE_TEST_CONTEXT['mediagoblin/root.html']
|
||||
session = context['request'].session
|
||||
assert session['user_id'] == unicode(test_user.id)
|
||||
assert session['user_id'] == six.text_type(test_user.id)
|
||||
|
||||
_test_registration()
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import pytest
|
||||
import six
|
||||
|
||||
from mediagoblin.tools import template
|
||||
from mediagoblin.tests.tools import (fixture_add_user, fixture_media_entry,
|
||||
@@ -75,7 +76,7 @@ class TestReportFiling:
|
||||
|
||||
response, context = self.do_post(
|
||||
{'report_reason':u'Testing Media Report',
|
||||
'reporter_id':unicode(allie_id)},url= media_uri_slug + "report/")
|
||||
'reporter_id':six.text_type(allie_id)},url= media_uri_slug + "report/")
|
||||
|
||||
assert response.status == "302 FOUND"
|
||||
|
||||
@@ -110,7 +111,7 @@ class TestReportFiling:
|
||||
|
||||
response, context = self.do_post({
|
||||
'report_reason':u'Testing Comment Report',
|
||||
'reporter_id':unicode(allie_id)},url= comment_uri_slug + "report/")
|
||||
'reporter_id':six.text_type(allie_id)},url= comment_uri_slug + "report/")
|
||||
|
||||
assert response.status == "302 FOUND"
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@ import os
|
||||
import tempfile
|
||||
|
||||
import pytest
|
||||
import six
|
||||
|
||||
from werkzeug.utils import secure_filename
|
||||
|
||||
from mediagoblin import storage
|
||||
@@ -78,7 +80,7 @@ def test_storage_system_from_config():
|
||||
'mediagoblin.tests.test_storage:FakeStorageSystem'})
|
||||
assert this_storage.foobie == 'eiboof'
|
||||
assert this_storage.blech == 'hcelb'
|
||||
assert unicode(this_storage.__class__) == \
|
||||
assert six.text_type(this_storage.__class__) == \
|
||||
u'mediagoblin.tests.test_storage.FakeStorageSystem'
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ sys.setdefaultencoding('utf-8')
|
||||
|
||||
import os
|
||||
import pytest
|
||||
import six
|
||||
|
||||
import six.moves.urllib.parse as urlparse
|
||||
|
||||
@@ -35,7 +36,7 @@ from .resources import GOOD_JPG, GOOD_PNG, EVIL_FILE, EVIL_JPG, EVIL_PNG, \
|
||||
BIG_BLUE, GOOD_PDF, GPS_JPG, MED_PNG, BIG_PNG
|
||||
|
||||
GOOD_TAG_STRING = u'yin,yang'
|
||||
BAD_TAG_STRING = unicode('rage,' + 'f' * 26 + 'u' * 26)
|
||||
BAD_TAG_STRING = six.text_type('rage,' + 'f' * 26 + 'u' * 26)
|
||||
|
||||
FORM_CONTEXT = ['mediagoblin/submit/start.html', 'submit_form']
|
||||
REQUEST_CONTEXT = ['mediagoblin/user_pages/user.html', 'request']
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
import email
|
||||
|
||||
import six
|
||||
|
||||
from mediagoblin.tools import common, url, translate, mail, text, testing
|
||||
|
||||
testing._activate_testing()
|
||||
@@ -117,13 +119,13 @@ def test_gettext_lazy_proxy():
|
||||
orig = u"Password"
|
||||
|
||||
set_thread_locale("es")
|
||||
p1 = unicode(proxy)
|
||||
p1 = six.text_type(proxy)
|
||||
p1_should = pass_to_ugettext(orig)
|
||||
assert p1_should != orig, "Test useless, string not translated"
|
||||
assert p1 == p1_should
|
||||
|
||||
set_thread_locale("sv")
|
||||
p2 = unicode(proxy)
|
||||
p2 = six.text_type(proxy)
|
||||
p2_should = pass_to_ugettext(orig)
|
||||
assert p2_should != orig, "Test broken, string not translated"
|
||||
assert p2 == p2_should
|
||||
|
||||
Reference in New Issue
Block a user