Fixed mistakes in tests unveiled by version bump to 1.8.1.

Forwardport of e7366ab1f9 from stable/1.8.x
This commit is contained in:
Tim Graham 2015-04-01 19:15:27 -04:00
parent 8f98732379
commit 0f941f57ba
3 changed files with 14 additions and 13 deletions

View File

@ -9,7 +9,7 @@ from django.core.files.temp import NamedTemporaryFile
from django.db import DJANGO_VERSION_PICKLE_KEY, models
from django.test import TestCase
from django.utils.encoding import force_text
from django.utils.version import get_major_version, get_version
from django.utils.version import get_version
from .models import Article
@ -47,17 +47,18 @@ class ModelPickleTestCase(TestCase):
def __reduce__(self):
reduce_list = super(DifferentDjangoVersion, self).__reduce__()
data = reduce_list[-1]
data[DJANGO_VERSION_PICKLE_KEY] = str(float(get_major_version()) - 0.1)
data[DJANGO_VERSION_PICKLE_KEY] = '1.0'
return reduce_list
p = DifferentDjangoVersion(title="FooBar")
with warnings.catch_warnings(record=True) as recorded:
pickle.loads(pickle.dumps(p))
msg = force_text(recorded.pop().message)
self.assertEqual(msg,
"Pickled model instance's Django version %s does not "
"match the current version %s."
% (str(float(get_major_version()) - 0.1), get_version()))
self.assertEqual(
msg,
"Pickled model instance's Django version 1.0 does not "
"match the current version %s." % get_version()
)
def test_unpickling_when_appregistrynotready(self):
"""

View File

@ -2,7 +2,6 @@ import datetime
from django.db import DJANGO_VERSION_PICKLE_KEY, models
from django.utils.translation import ugettext_lazy as _
from django.utils.version import get_major_version
def standalone_number():
@ -27,7 +26,7 @@ nn = Numbers()
class PreviousDjangoVersionQuerySet(models.QuerySet):
def __getstate__(self):
state = super(PreviousDjangoVersionQuerySet, self).__getstate__()
state[DJANGO_VERSION_PICKLE_KEY] = str(float(get_major_version()) - 0.1) # previous major version
state[DJANGO_VERSION_PICKLE_KEY] = '1.0'
return state

View File

@ -6,7 +6,7 @@ import warnings
from django.test import TestCase
from django.utils.encoding import force_text
from django.utils.version import get_major_version, get_version
from django.utils.version import get_version
from .models import Container, Event, Group, Happening, M2MModel
@ -140,7 +140,8 @@ class PickleabilityTestCase(TestCase):
with warnings.catch_warnings(record=True) as recorded:
pickle.loads(pickle.dumps(qs))
msg = force_text(recorded.pop().message)
self.assertEqual(msg,
"Pickled queryset instance's Django version %s does not "
"match the current version %s."
% (str(float(get_major_version()) - 0.1), get_version()))
self.assertEqual(
msg,
"Pickled queryset instance's Django version 1.0 does not "
"match the current version %s." % get_version()
)