Skip to content

Commit 237d961

Browse files
authored
Add support for Python 3.9 (#658)
* Add support for Python 3.9 Move haystack tox dependency only when testing with search features
1 parent 6795ae5 commit 237d961

File tree

7 files changed

+25
-17
lines changed

7 files changed

+25
-17
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,10 @@ jobs:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
python-version: [3.8, 3.7, 3.6, 3.5]
11+
python-version: [3.9, 3.8, 3.7, 3.6]
1212
django: [31, 30, 22]
1313
cms: [38, 37]
1414
exclude:
15-
- python-version: 3.5
16-
django: 30
17-
- python-version: 3.5
18-
django: 31
1915
- django: 31
2016
cms: 37
2117
include:

changes/657.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add support for Python 3.9

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ classifiers =
4343
Framework :: Django :: 3.1
4444
Programming Language :: Python
4545
Programming Language :: Python :: 3
46-
Programming Language :: Python :: 3.5
4746
Programming Language :: Python :: 3.6
4847
Programming Language :: Python :: 3.7
4948
Programming Language :: Python :: 3.8
49+
Programming Language :: Python :: 3.9
5050

5151
[options]
5252
include_package_data = True

tests/base.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
from django.contrib.auth import get_user_model
77
from django.contrib.sites.models import Site
88
from django.core.cache import cache
9-
from haystack import connections
10-
from haystack.constants import DEFAULT_ALIAS
119
from menus.menu_pool import menu_pool
1210
from parler.utils.context import smart_override
1311

@@ -257,6 +255,9 @@ def get_posts(self, sites=None):
257255
return posts
258256

259257
def get_post_index(self):
258+
from haystack import connections
259+
from haystack.constants import DEFAULT_ALIAS
260+
260261
search_conn = connections[DEFAULT_ALIAS]
261262
unified_index = search_conn.get_unified_index()
262263
index = unified_index.get_index(Post)

tests/test_indexing.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
from cms.api import add_plugin
44
from django.test import override_settings
5-
from haystack.constants import DEFAULT_ALIAS
6-
from haystack.query import SearchQuerySet
75

86
from djangocms_blog.models import Post
97

@@ -14,6 +12,13 @@
1412
except ImportError:
1513
aldryn_search = None
1614

15+
try:
16+
import haystack
17+
from haystack.constants import DEFAULT_ALIAS
18+
from haystack.query import SearchQuerySet
19+
except ImportError:
20+
haystack = None
21+
1722

1823
class BlogIndexingTests(BaseTest):
1924
sample_text = "First post first line This is the description keyword1 keyword2 category 1 a tag test body"
@@ -22,6 +27,7 @@ def setUp(self):
2227
self.get_pages()
2328

2429
@skipIf(aldryn_search is None, "aldryn-search not installed")
30+
@skipIf(haystack is None, "haystack not installed")
2531
def test_blog_post_is_indexed_using_prepare(self):
2632
"""This tests the indexing path way used by update_index mgmt command"""
2733
post = self._get_post(self._post_data[0]["en"])
@@ -41,6 +47,7 @@ def test_blog_post_is_indexed_using_prepare(self):
4147
self.assertEqual(post.date_published, indexed["pub_date"])
4248

4349
@skipIf(aldryn_search is None, "aldryn-search not installed")
50+
@skipIf(haystack is None, "haystack not installed")
4451
@override_settings(BLOG_USE_PLACEHOLDER=False)
4552
def test_blog_post_is_indexed_using_prepare_no_placeholder(self):
4653
"""This tests the indexing path way used by update_index mgmt command when not using placeholder content"""
@@ -62,6 +69,7 @@ def test_blog_post_is_indexed_using_prepare_no_placeholder(self):
6269
self.assertEqual(post.get_absolute_url(), indexed["url"])
6370
self.assertEqual(post.date_published, indexed["pub_date"])
6471

72+
@skipIf(haystack is None, "haystack not installed")
6573
def test_searchqueryset(self):
6674
posts = self.get_posts()
6775
all_results = SearchQuerySet().models(Post)

tests/test_models.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,10 @@ def test_urls(self):
10611061
post.app_config = self.app_config_1
10621062

10631063
self.assertTrue(
1064-
re.match(r".*{}/{}/$".format(urlquote(post.categories.first().slug), urlquote(post.slug)), post.get_absolute_url())
1064+
re.match(
1065+
r".*{}/{}/$".format(urlquote(post.categories.first().slug), urlquote(post.slug)),
1066+
post.get_absolute_url(),
1067+
)
10651068
)
10661069

10671070
# slug only

tox.ini

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ envlist =
88
pep8
99
pypi-description
1010
towncrier
11-
py{38,37,36}-django{31}-cms{38,no-search-38}
12-
py{38,37,36}-django{30}-cms{38,37,no-search-37}
13-
py{38,37,36,35}-django{22}-cms{38,37,no-search-37}
11+
py{39,38,37,36}-django{31}-cms{38,no-search-38}
12+
py{39,38,37,36}-django{30}-cms{38,37,no-search-37}
13+
py{39,38,37,36,35}-django{22}-cms{38,37,no-search-37}
1414

1515
[testenv]
1616
commands = {env:COMMAND:python} cms_helper.py djangocms_blog test {posargs}
@@ -19,22 +19,21 @@ deps =
1919
django22: django-mptt>=0.8
2020
django22: django-filer>=1.5,<1.6
2121
django22: django-appdata>=0.2.2
22-
django22: django-haystack
2322
django30: Django>=3.0,<3.1
2423
django30: django-mptt>=0.9
2524
django30: django-filer>=1.6
2625
django30: django-appdata>=0.3.0
27-
django30: django-haystack==3.0b2
2826
django31: Django>=3.1,<3.2
2927
django31: django-mptt>=0.9
3028
django31: django-filer>=2.0
3129
django31: django-appdata>=0.3.2
32-
django31: django-haystack==3.0b2
3330
cms37: https://github.com/divio/django-cms/archive/release/3.7.x.zip
3431
cms37: aldryn-search
32+
cms37: django-haystack==3.0b2
3533
cms-no-search-37: https://github.com/divio/django-cms/archive/release/3.7.x.zip
3634
cms38: https://github.com/divio/django-cms/archive/release/3.8.x.zip
3735
cms38: aldryn-search
36+
cms38: django-haystack==3.0b2
3837
cms-no-search-38: https://github.com/divio/django-cms/archive/release/3.8.x.zip
3938
channels>2,<3
4039
https://github.com/nephila/django-knocker/archive/master.zip

0 commit comments

Comments
 (0)