forked from pool/python-django-haystack
Compare commits
23 Commits
| Author | SHA256 | Date | |
|---|---|---|---|
| 82987934db | |||
| 342e9f5255 | |||
| e526c14be8 | |||
| a088ae69e8 | |||
|
|
46c5ef237e | ||
| d4b7d5f806 | |||
|
|
e6d5204316 | ||
| fd885f9cbf | |||
| 13f01bc04c | |||
| ae6a623c65 | |||
|
|
2e47fbca25 | ||
| e2065076df | |||
|
|
2b446d6a04 | ||
| 88b587d0d3 | |||
|
|
bfb26cc7fc | ||
| c893f1f497 | |||
| 5c258c743e | |||
| 9d9664d865 | |||
| cea9a90225 | |||
| 8d5227076d | |||
|
|
f4315af56f | ||
| e62f895e9c | |||
|
|
8529517150 |
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:97e3197aefc225fe405b6f17600a2534bf827cb4d6743130c20bc1a06f7293a4
|
||||
size 466580
|
||||
@@ -1,68 +0,0 @@
|
||||
From da4651508e5d79e889fa2a7db5c0e40418703498 Mon Sep 17 00:00:00 2001
|
||||
From: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
|
||||
Date: Fri, 12 Jan 2024 23:12:29 +0100
|
||||
Subject: [PATCH] Migrate away from pkg_resources
|
||||
|
||||
Using pkg_resources as an API is deprecated.
|
||||
Migrate functionality to their importlib and packaging equivalents.
|
||||
|
||||
Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
|
||||
---
|
||||
haystack/__init__.py | 13 +++++++------
|
||||
test_haystack/solr_tests/test_solr_backend.py | 4 ++--
|
||||
2 files changed, 9 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/haystack/__init__.py b/haystack/__init__.py
|
||||
index 94b8f4674..25448de96 100644
|
||||
--- a/haystack/__init__.py
|
||||
+++ b/haystack/__init__.py
|
||||
@@ -1,7 +1,9 @@
|
||||
+from importlib.metadata import PackageNotFoundError, version
|
||||
+
|
||||
import django
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
-from pkg_resources import DistributionNotFound, get_distribution, parse_version
|
||||
+from packaging.version import Version
|
||||
|
||||
from haystack.constants import DEFAULT_ALIAS
|
||||
from haystack.utils import loading
|
||||
@@ -9,12 +11,11 @@
|
||||
__author__ = "Daniel Lindsley"
|
||||
|
||||
try:
|
||||
- pkg_distribution = get_distribution("django-haystack")
|
||||
- __version__ = pkg_distribution.version
|
||||
- version_info = pkg_distribution.parsed_version
|
||||
-except DistributionNotFound:
|
||||
+ __version__ = version("django-haystack")
|
||||
+ version_info = Version(__version__)
|
||||
+except PackageNotFoundError:
|
||||
__version__ = "0.0.dev0"
|
||||
- version_info = parse_version(__version__)
|
||||
+ version_info = Version(__version__)
|
||||
|
||||
|
||||
if django.VERSION < (3, 2):
|
||||
diff --git a/test_haystack/solr_tests/test_solr_backend.py b/test_haystack/solr_tests/test_solr_backend.py
|
||||
index d20347e7e..d8c95d329 100644
|
||||
--- a/test_haystack/solr_tests/test_solr_backend.py
|
||||
+++ b/test_haystack/solr_tests/test_solr_backend.py
|
||||
@@ -10,7 +10,7 @@
|
||||
from django.conf import settings
|
||||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
-from pkg_resources import parse_version
|
||||
+from packaging.version import Version
|
||||
|
||||
from haystack import connections, indexes, reset_search_queries
|
||||
from haystack.exceptions import SkipDocument
|
||||
@@ -1650,7 +1650,7 @@ def test_boost(self):
|
||||
|
||||
|
||||
@unittest.skipIf(
|
||||
- parse_version(pysolr.__version__) < parse_version("3.1.1"),
|
||||
+ Version(pysolr.__version__) < Version("3.1.1"),
|
||||
"content extraction requires pysolr > 3.1.1",
|
||||
)
|
||||
class LiveSolrContentExtractionTestCase(TestCase):
|
||||
@@ -1,82 +0,0 @@
|
||||
From 3a566a50e4963bed4fb8853eca60bc894b0b7fc5 Mon Sep 17 00:00:00 2001
|
||||
From: Christian Clauss <cclauss@me.com>
|
||||
Date: Mon, 1 Jan 2024 19:53:28 +0100
|
||||
Subject: [PATCH] Fix unittest assert calls for Python 3.12
|
||||
|
||||
---
|
||||
test_haystack/test_managers.py | 4 ++--
|
||||
test_haystack/test_query.py | 20 ++++++++++----------
|
||||
2 files changed, 12 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/test_haystack/test_managers.py b/test_haystack/test_managers.py
|
||||
index 3784217cd..cc600752e 100644
|
||||
--- a/test_haystack/test_managers.py
|
||||
+++ b/test_haystack/test_managers.py
|
||||
@@ -242,11 +242,11 @@ def spelling_suggestion(self):
|
||||
|
||||
def test_values(self):
|
||||
sqs = self.search_index.objects.auto_query("test").values("id")
|
||||
- self.assert_(isinstance(sqs, ValuesSearchQuerySet))
|
||||
+ self.assertIsInstance(sqs, ValuesSearchQuerySet)
|
||||
|
||||
def test_valueslist(self):
|
||||
sqs = self.search_index.objects.auto_query("test").values_list("id")
|
||||
- self.assert_(isinstance(sqs, ValuesListSearchQuerySet))
|
||||
+ self.assertIsInstance(sqs, ValuesListSearchQuerySet)
|
||||
|
||||
|
||||
class CustomManagerTestCase(TestCase):
|
||||
diff --git a/test_haystack/test_query.py b/test_haystack/test_query.py
|
||||
index ffe35c19a..f7e9a1707 100644
|
||||
--- a/test_haystack/test_query.py
|
||||
+++ b/test_haystack/test_query.py
|
||||
@@ -442,7 +442,7 @@ def test_len(self):
|
||||
def test_repr(self):
|
||||
reset_search_queries()
|
||||
self.assertEqual(len(connections["default"].queries), 0)
|
||||
- self.assertRegexpMatches(
|
||||
+ self.assertRegex(
|
||||
repr(self.msqs),
|
||||
r"^<SearchQuerySet: query=<test_haystack.mocks.MockSearchQuery object"
|
||||
r" at 0x[0-9A-Fa-f]+>, using=None>$",
|
||||
@@ -967,18 +967,18 @@ def test_or_and(self):
|
||||
class ValuesQuerySetTestCase(SearchQuerySetTestCase):
|
||||
def test_values_sqs(self):
|
||||
sqs = self.msqs.auto_query("test").values("id")
|
||||
- self.assert_(isinstance(sqs, ValuesSearchQuerySet))
|
||||
+ self.assertIsInstance(sqs, ValuesSearchQuerySet)
|
||||
|
||||
# We'll do a basic test to confirm that slicing works as expected:
|
||||
- self.assert_(isinstance(sqs[0], dict))
|
||||
- self.assert_(isinstance(sqs[0:5][0], dict))
|
||||
+ self.assertIsInstance(sqs[0], dict)
|
||||
+ self.assertIsInstance(sqs[0:5][0], dict)
|
||||
|
||||
def test_valueslist_sqs(self):
|
||||
sqs = self.msqs.auto_query("test").values_list("id")
|
||||
|
||||
- self.assert_(isinstance(sqs, ValuesListSearchQuerySet))
|
||||
- self.assert_(isinstance(sqs[0], (list, tuple)))
|
||||
- self.assert_(isinstance(sqs[0:1][0], (list, tuple)))
|
||||
+ self.assertIsInstance(sqs, ValuesListSearchQuerySet)
|
||||
+ self.assertIsInstance(sqs[0], (list, tuple))
|
||||
+ self.assertIsInstance(sqs[0:1][0], (list, tuple))
|
||||
|
||||
self.assertRaises(
|
||||
TypeError,
|
||||
@@ -989,12 +989,12 @@ def test_valueslist_sqs(self):
|
||||
)
|
||||
|
||||
flat_sqs = self.msqs.auto_query("test").values_list("id", flat=True)
|
||||
- self.assert_(isinstance(sqs, ValuesListSearchQuerySet))
|
||||
+ self.assertIsInstance(sqs, ValuesListSearchQuerySet)
|
||||
|
||||
# Note that this will actually be None because a mocked sqs lacks
|
||||
# anything else:
|
||||
- self.assert_(flat_sqs[0] is None)
|
||||
- self.assert_(flat_sqs[0:1][0] is None)
|
||||
+ self.assertIsNone(flat_sqs[0])
|
||||
+ self.assertIsNone(flat_sqs[0:1][0])
|
||||
|
||||
|
||||
class EmptySearchQuerySetTestCase(TestCase):
|
||||
Reference in New Issue
Block a user