[1.8.x] Fixed mistakes in tests unveiled by version bump to 1.8.1.

This commit is contained in:
Tim Graham 2015-04-01 19:15:27 -04:00
parent b0512db5c4
commit e7366ab1f9
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.db import DJANGO_VERSION_PICKLE_KEY, models
from django.test import TestCase from django.test import TestCase
from django.utils.encoding import force_text 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 from .models import Article
@ -47,17 +47,18 @@ class ModelPickleTestCase(TestCase):
def __reduce__(self): def __reduce__(self):
reduce_list = super(DifferentDjangoVersion, self).__reduce__() reduce_list = super(DifferentDjangoVersion, self).__reduce__()
data = reduce_list[-1] 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 return reduce_list
p = DifferentDjangoVersion(title="FooBar") p = DifferentDjangoVersion(title="FooBar")
with warnings.catch_warnings(record=True) as recorded: with warnings.catch_warnings(record=True) as recorded:
pickle.loads(pickle.dumps(p)) pickle.loads(pickle.dumps(p))
msg = force_text(recorded.pop().message) msg = force_text(recorded.pop().message)
self.assertEqual(msg, self.assertEqual(
"Pickled model instance's Django version %s does not " msg,
"match the current version %s." "Pickled model instance's Django version 1.0 does not "
% (str(float(get_major_version()) - 0.1), get_version())) "match the current version %s." % get_version()
)
def test_unpickling_when_appregistrynotready(self): 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.db import DJANGO_VERSION_PICKLE_KEY, models
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.utils.version import get_major_version
def standalone_number(): def standalone_number():
@ -27,7 +26,7 @@ nn = Numbers()
class PreviousDjangoVersionQuerySet(models.QuerySet): class PreviousDjangoVersionQuerySet(models.QuerySet):
def __getstate__(self): def __getstate__(self):
state = super(PreviousDjangoVersionQuerySet, self).__getstate__() 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 return state

View File

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