From e7366ab1f908b8cbf8d7e83037b5f17d101b5ade Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Wed, 1 Apr 2015 19:15:27 -0400 Subject: [PATCH] [1.8.x] Fixed mistakes in tests unveiled by version bump to 1.8.1. --- tests/model_regress/test_pickle.py | 13 +++++++------ tests/queryset_pickle/models.py | 3 +-- tests/queryset_pickle/tests.py | 11 ++++++----- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/tests/model_regress/test_pickle.py b/tests/model_regress/test_pickle.py index 996c2221d6..1666eb2549 100644 --- a/tests/model_regress/test_pickle.py +++ b/tests/model_regress/test_pickle.py @@ -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): """ diff --git a/tests/queryset_pickle/models.py b/tests/queryset_pickle/models.py index 6503d1f33a..77134a5018 100644 --- a/tests/queryset_pickle/models.py +++ b/tests/queryset_pickle/models.py @@ -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 diff --git a/tests/queryset_pickle/tests.py b/tests/queryset_pickle/tests.py index d735413e1f..0125c158af 100644 --- a/tests/queryset_pickle/tests.py +++ b/tests/queryset_pickle/tests.py @@ -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 @@ -141,7 +141,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() + )