summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAdam Johnson <me@adamj.eu>2020-04-03 21:13:02 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-05-11 09:50:11 +0200
commita8b2db1cae581d083db999ffeb8244864e6be125 (patch)
tree0f2464d61f476131eb0786a601fc64dfdde2aa09 /tests
parent72a170b4c3c4c2db8192bb1a6424bcc8eb533973 (diff)
Optimized Model and QuerySet pickling version comparison.
Diffstat (limited to 'tests')
-rw-r--r--tests/model_regress/test_pickle.py7
-rw-r--r--tests/queryset_pickle/tests.py7
2 files changed, 10 insertions, 4 deletions
diff --git a/tests/model_regress/test_pickle.py b/tests/model_regress/test_pickle.py
index f8676404c0..6a09c3734f 100644
--- a/tests/model_regress/test_pickle.py
+++ b/tests/model_regress/test_pickle.py
@@ -1,8 +1,8 @@
import pickle
+import django
from django.db import DJANGO_VERSION_PICKLE_KEY, models
from django.test import SimpleTestCase
-from django.utils.version import get_version
class ModelPickleTests(SimpleTestCase):
@@ -40,7 +40,10 @@ class ModelPickleTests(SimpleTestCase):
return reduce_list
p = DifferentDjangoVersion(title="FooBar")
- msg = "Pickled model instance's Django version 1.0 does not match the current version %s." % get_version()
+ msg = (
+ "Pickled model instance's Django version 1.0 does not match the "
+ "current version %s." % django.__version__
+ )
with self.assertRaisesMessage(RuntimeWarning, msg):
pickle.loads(pickle.dumps(p))
diff --git a/tests/queryset_pickle/tests.py b/tests/queryset_pickle/tests.py
index 793141cfdd..baf2e96aaf 100644
--- a/tests/queryset_pickle/tests.py
+++ b/tests/queryset_pickle/tests.py
@@ -1,9 +1,9 @@
import datetime
import pickle
+import django
from django.db import models
from django.test import TestCase
-from django.utils.version import get_version
from .models import Container, Event, Group, Happening, M2MModel, MyEvent
@@ -234,7 +234,10 @@ class PickleabilityTestCase(TestCase):
unpickled with a different Django version than the current
"""
qs = Group.previous_django_version_objects.all()
- msg = "Pickled queryset instance's Django version 1.0 does not match the current version %s." % get_version()
+ msg = (
+ "Pickled queryset instance's Django version 1.0 does not match "
+ "the current version %s." % django.__version__
+ )
with self.assertRaisesMessage(RuntimeWarning, msg):
pickle.loads(pickle.dumps(qs))