1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

[py3] Ported django.utils.encoding.

* Renamed smart_unicode to smart_text (but kept the old name under
  Python 2 for backwards compatibility).
* Renamed smart_str to smart_bytes.
* Re-introduced smart_str as an alias for smart_text under Python 3
  and smart_bytes under Python 2 (which is backwards compatible).
  Thus smart_str always returns a str objects.
* Used the new smart_str in a few places where both Python 2 and 3
  want a str.
This commit is contained in:
Aymeric Augustin
2012-07-21 10:00:10 +02:00
parent ee191715ea
commit c5ef65bcf3
125 changed files with 629 additions and 583 deletions

View File

@@ -28,7 +28,7 @@ from django.test.utils import (get_warnings_state, restore_warnings_state,
from django.utils import timezone, translation, unittest
from django.utils.cache import (patch_vary_headers, get_cache_key,
learn_cache_key, patch_cache_control, patch_response_headers)
from django.utils.encoding import force_unicode
from django.utils.encoding import force_text
from django.views.decorators.cache import cache_page
from .models import Poll, expensive_calculation
@@ -1307,7 +1307,7 @@ class CacheI18nTest(TestCase):
request = self._get_request()
# This is tightly coupled to the implementation,
# but it's the most straightforward way to test the key.
tz = force_unicode(timezone.get_current_timezone_name(), errors='ignore')
tz = force_text(timezone.get_current_timezone_name(), errors='ignore')
tz = tz.encode('ascii', 'ignore').replace(' ', '_')
response = HttpResponse()
key = learn_cache_key(request, response)
@@ -1319,7 +1319,7 @@ class CacheI18nTest(TestCase):
def test_cache_key_no_i18n (self):
request = self._get_request()
lang = translation.get_language()
tz = force_unicode(timezone.get_current_timezone_name(), errors='ignore')
tz = force_text(timezone.get_current_timezone_name(), errors='ignore')
tz = tz.encode('ascii', 'ignore').replace(' ', '_')
response = HttpResponse()
key = learn_cache_key(request, response)