mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Merge branch 'master' into schema-alteration
This commit is contained in:
@@ -3,7 +3,7 @@ from __future__ import unicode_literals
|
||||
import json
|
||||
|
||||
from django.db import models
|
||||
from django.utils.encoding import force_unicode
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils import six
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ class Small(object):
|
||||
self.first, self.second = first, second
|
||||
|
||||
def __unicode__(self):
|
||||
return '%s%s' % (force_unicode(self.first), force_unicode(self.second))
|
||||
return '%s%s' % (force_text(self.first), force_text(self.second))
|
||||
|
||||
def __str__(self):
|
||||
return six.text_type(self).encode('utf-8')
|
||||
@@ -46,9 +46,9 @@ class SmallField(models.Field):
|
||||
|
||||
def get_prep_lookup(self, lookup_type, value):
|
||||
if lookup_type == 'exact':
|
||||
return force_unicode(value)
|
||||
return force_text(value)
|
||||
if lookup_type == 'in':
|
||||
return [force_unicode(v) for v in value]
|
||||
return [force_text(v) for v in value]
|
||||
if lookup_type == 'isnull':
|
||||
return []
|
||||
raise TypeError('Invalid lookup type: %r' % lookup_type)
|
||||
|
||||
@@ -5,7 +5,7 @@ Tests for field subclassing.
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.db import models
|
||||
from django.utils.encoding import force_unicode
|
||||
from django.utils.encoding import force_text
|
||||
|
||||
from .fields import SmallField, SmallerField, JSONField
|
||||
|
||||
@@ -15,7 +15,7 @@ class MyModel(models.Model):
|
||||
data = SmallField('small field')
|
||||
|
||||
def __unicode__(self):
|
||||
return force_unicode(self.name)
|
||||
return force_text(self.name)
|
||||
|
||||
class OtherModel(models.Model):
|
||||
data = SmallerField()
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
import StringIO
|
||||
|
||||
from django.contrib.sites.models import Site
|
||||
from django.core import management
|
||||
from django.db import connection, IntegrityError
|
||||
from django.test import TestCase, TransactionTestCase, skipUnlessDBFeature
|
||||
from django.utils.six import StringIO
|
||||
|
||||
from .models import Article, Book, Spy, Tag, Visa
|
||||
|
||||
@@ -26,7 +25,7 @@ class FixtureLoadingTests(TestCase):
|
||||
|
||||
def _dumpdata_assert(self, args, output, format='json', natural_keys=False,
|
||||
use_base_manager=False, exclude_list=[]):
|
||||
new_io = StringIO.StringIO()
|
||||
new_io = StringIO()
|
||||
management.call_command('dumpdata', *args, **{'format':format,
|
||||
'stdout':new_io,
|
||||
'stderr':new_io,
|
||||
@@ -43,7 +42,7 @@ class FixtureLoadingTests(TestCase):
|
||||
])
|
||||
|
||||
def test_loading_and_dumping(self):
|
||||
new_io = StringIO.StringIO()
|
||||
new_io = StringIO()
|
||||
|
||||
Site.objects.all().delete()
|
||||
# Load fixture 1. Single JSON file, with two objects.
|
||||
@@ -293,7 +292,7 @@ class FixtureLoadingTests(TestCase):
|
||||
|
||||
class FixtureTransactionTests(TransactionTestCase):
|
||||
def _dumpdata_assert(self, args, output, format='json'):
|
||||
new_io = StringIO.StringIO()
|
||||
new_io = StringIO()
|
||||
management.call_command('dumpdata', *args, **{'format':format, 'stdout':new_io})
|
||||
command_output = new_io.getvalue().strip()
|
||||
self.assertEqual(command_output, output)
|
||||
|
||||
@@ -638,8 +638,7 @@ class OldFormForXTests(TestCase):
|
||||
f = BaseCategoryForm({'name': '', 'slug': 'not a slug!', 'url': 'foo'})
|
||||
self.assertEqual(f.errors['name'], ['This field is required.'])
|
||||
self.assertEqual(f.errors['slug'], ["Enter a valid 'slug' consisting of letters, numbers, underscores or hyphens."])
|
||||
with self.assertRaises(AttributeError):
|
||||
f.cleaned_data
|
||||
self.assertEqual(f.cleaned_data, {'url': 'foo'})
|
||||
with self.assertRaises(ValueError):
|
||||
f.save()
|
||||
f = BaseCategoryForm({'name': '', 'slug': '', 'url': 'foo'})
|
||||
|
||||
@@ -4,13 +4,13 @@ from __future__ import absolute_import, unicode_literals
|
||||
import json
|
||||
from datetime import datetime
|
||||
from xml.dom import minidom
|
||||
from StringIO import StringIO
|
||||
|
||||
from django.conf import settings
|
||||
from django.core import serializers
|
||||
from django.db import transaction, connection
|
||||
from django.test import TestCase, TransactionTestCase, Approximate
|
||||
from django.utils import six
|
||||
from django.utils.six import StringIO
|
||||
from django.utils import unittest
|
||||
|
||||
from .models import (Category, Author, Article, AuthorProfile, Actor, Movie,
|
||||
|
||||
@@ -20,6 +20,7 @@ from django.http import HttpRequest
|
||||
from django.template import Context, RequestContext, Template, TemplateSyntaxError
|
||||
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
|
||||
from django.test.utils import override_settings
|
||||
from django.utils import six
|
||||
from django.utils import timezone
|
||||
from django.utils.tzinfo import FixedOffset
|
||||
from django.utils.unittest import skipIf, skipUnless
|
||||
@@ -690,8 +691,8 @@ class TemplateTests(TestCase):
|
||||
}
|
||||
}
|
||||
|
||||
for k1, dt in datetimes.iteritems():
|
||||
for k2, tpl in templates.iteritems():
|
||||
for k1, dt in six.iteritems(datetimes):
|
||||
for k2, tpl in six.iteritems(templates):
|
||||
ctx = Context({'dt': dt, 'ICT': ICT})
|
||||
actual = tpl.render(ctx)
|
||||
expected = results[k1][k2]
|
||||
@@ -703,8 +704,8 @@ class TemplateTests(TestCase):
|
||||
results['ict']['notag'] = t('ict', 'eat', 'utc', 'ict')
|
||||
|
||||
with self.settings(USE_TZ=False):
|
||||
for k1, dt in datetimes.iteritems():
|
||||
for k2, tpl in templates.iteritems():
|
||||
for k1, dt in six.iteritems(datetimes):
|
||||
for k2, tpl in six.iteritems(templates):
|
||||
ctx = Context({'dt': dt, 'ICT': ICT})
|
||||
actual = tpl.render(ctx)
|
||||
expected = results[k1][k2]
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import sys
|
||||
from StringIO import StringIO
|
||||
|
||||
from django.core import management
|
||||
from django.core.management.base import CommandError
|
||||
from django.test import TestCase
|
||||
from django.utils import translation
|
||||
from django.utils.six import StringIO
|
||||
|
||||
|
||||
class CommandTests(TestCase):
|
||||
|
||||
@@ -101,6 +101,6 @@ try:
|
||||
class MultipleAutoFields(models.Model):
|
||||
auto1 = models.AutoField(primary_key=True)
|
||||
auto2 = models.AutoField(primary_key=True)
|
||||
except AssertionError as assertion_error:
|
||||
pass # Fail silently
|
||||
except AssertionError as exc:
|
||||
assertion_error = exc
|
||||
assert str(assertion_error) == "A model can't have more than one AutoField."
|
||||
|
||||
Reference in New Issue
Block a user