8000 fix: #7662, add support for python 3.12 and upgrade github actions by vinitkumar · Pull Request #7680 · django-cms/django-cms · GitHub
[go: up one dir, main page]

Skip to content

fix: #7662, add support for python 3.12 and upgrade github actions #7680

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8000
Prev Previous commit
Next Next commit
fix: deprecations
  • Loading branch information
Vinit Kumar committed Oct 18, 2023
commit c5018332dec6ea94c6ff319a8bb729ea75f1e399
20 changes: 10 additions & 10 deletions cms/tests/test_nested_plugins.py
8000
Original file line number Diff line number Diff line change
Expand Up @@ -607,13 +607,13 @@ def test_copy_page_nested_plugin(self):
# check the stored placeholders org vs copy
msg = 'placehoder ids copy:%s org:%s copied page %s are identical - tree broken' % (
page_two_ph_one.pk, page_one_ph_one.pk, page_two.pk)
self.assertNotEquals(page_two_ph_one.pk, page_one_ph_one.pk, msg)
self.assertNotEqual(page_two_ph_one.pk, page_one_ph_one.pk, msg)
msg = 'placehoder ids copy:%s org:%s copied page %s are identical - tree broken' % (
page_two_ph_two.pk, page_one_ph_two.pk, page_two.pk)
self.assertNotEquals(page_two_ph_two.pk, page_one_ph_two.pk, msg)
self.assertNotEqual(page_two_ph_two.pk, page_one_ph_two.pk, msg)
msg = 'placehoder ids copy:%s org:%s copied page %s are identical - tree broken' % (
page_two_ph_three.pk, page_one_ph_three.pk, page_two.pk)
self.assertNotEquals(page_two_ph_three.pk, page_one_ph_three.pk, msg)
self.assertNotEqual(page_two_ph_three.pk, page_one_ph_three.pk, msg)
# get the plugins from the original page
org_placeholder_one_plugins = page_one_ph_one.get_plugins()
self.assertEqual(len(org_placeholder_one_plugins), 1)
Expand Down Expand Up @@ -664,9 +664,9 @@ def test_copy_page_nested_plugin(self):
copied_nested_text_plugin = instance
break
msg = "orginal nested text plugin not found"
self.assertNotEquals(org_nested_text_plugin, None, msg=msg)
self.assertNotEqual(org_nested_text_plugin, None, msg=msg)
msg = "copied nested text plugin not found"
self.assertNotEquals(copied_nested_text_plugin, None, msg=msg)
self.assertNotEqual(copied_nested_text_plugin, None, msg=msg)
# get the children ids of the texplugin with a nested link
# to check if the body of the text is genrated correctly
org_link_child_plugin = org_nested_text_plugin.get_children()[0]
Expand Down Expand Up @@ -839,13 +839,13 @@ def test_copy_page_nested_plugin_moved_parent_plugin(self):
# check the stored placeholders org vs copy
msg = u'placehoder ids copy:%s org:%s copied page %s are identical - tree broken' % (
page_two_ph_one.pk, page_one_ph_one.pk, page_two.pk)
self.assertNotEquals(page_two_ph_one.pk, page_one_ph_one.pk, msg)
self.assertNotEqual(page_two_ph_one.pk, page_one_ph_one.pk, msg)
msg = u'placehoder ids copy:%s org:%s copied page %s are identical - tree broken' % (
page_two_ph_two.pk, page_one_ph_two.pk, page_two.pk)
self.assertNotEquals(page_two_ph_two.pk, page_one_ph_two.pk, msg)
self.assertNotEqual(page_two_ph_two.pk, page_one_ph_two.pk, msg)
msg = u'placehoder ids copy:%s org:%s copied page %s are identical - tree broken' % (
page_two_ph_three.pk, page_one_ph_three.pk, page_two.pk)
self.assertNotEquals(page_two_ph_three.pk, page_one_ph_three.pk, msg)
self.assertNotEqual(page_two_ph_three.pk, page_one_ph_three.pk, msg)
# get the plugins from the original page
org_placeholder_one_plugins = page_one_ph_one.get_plugins()
self.assertEqual(len(org_placeholder_one_plugins), 1)
Expand Down Expand Up @@ -896,9 +896,9 @@ def test_copy_page_nested_plugin_moved_parent_plugin(self):
copied_nested_text_plugin = instance
break
msg = "orginal nested text plugin not found"
self.assertNotEquals(org_nested_text_plugin, None, msg=msg)
self.assertNotEqual(org_nested_text_plugin, None, msg=msg)
msg = "copied nested text plugin not found"
self.assertNotEquals(copied_nested_text_plugin, None, msg=msg)
self.assertNotEqual(copied_nested_text_plugin, None, msg=msg)
# get the children ids of the texplugin with a nested link
# to check if the body of the text is generated correctly
org_link_child_plugin = org_nested_text_plugin.get_children()[0]
Expand Down
6 changes: 3 additions & 3 deletions cms/tests/test_signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_urls_need_reloading_signal_set_apphook(self):
self.assertRedirects(response, redirect_to)
self.assertEqual(env.call_count, 1)
new_revision, _ = UrlconfRevision.get_or_create_revision()
self.assertNotEquals(current_revision, new_revision)
self.assertNotEqual(current_revision, new_revision)

def test_urls_need_reloading_signal_delete(self):
superuser = self.get_superuser()
Expand All @@ -63,7 +63,7 @@ def test_urls_need_reloading_signal_delete(self):
self.client.post(endpoint, {'post': 'yes'})
self.assertEqual(env.call_count, 1)
new_revision, _ = UrlconfRevision.get_or_create_revision()
self.assertNotEquals(current_revision, new_revision)
self.assertNotEqual(current_revision, new_revision)

def test_urls_need_reloading_signal_change_slug(self):
superuser = self.get_superuser()
Expand Down Expand Up @@ -92,4 +92,4 @@ def test_urls_need_reloading_signal_change_slug(self):
self.assertRedirects(response, redirect_to)
self.assertEqual(env.call_count, 1)
new_revision, _ = UrlconfRevision.get_or_create_revision()
self.assertNotEquals(current_revision, new_revision)
self.assertNotEqual(current_revision, new_revision)
34 changes: 20 additions & 14 deletions cms/tests/test_templates.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os.path
from imp import PY_SOURCE, load_module
from importlib.machinery import SourceFileLoader

from django.conf import settings
from django.template import TemplateDoesNotExist, loader
Expand Down Expand Up @@ -39,19 +39,25 @@ def test_custom_templates(self):
Test that using CMS_TEMPLATES_DIR both template list and template labels are extracted from the new directory
"""
config_path = os.path.join(settings.CMS_TEMPLATES_DIR, '__init__.py')
with open(config_path, 'r') as openfile:
mod = load_module("mod", openfile, config_path, ('m', 'r', PY_SOURCE))
original_labels = [force_str(_(template[1])) for template in mod.TEMPLATES.items()]
original_files = [os.path.join(PATH_PREFIX, template[0].strip()) for template in mod.TEMPLATES.items()]
templates = get_cms_setting('TEMPLATES')
self.assertEqual(len(templates), 3)
labels = [force_str(template[1]) for template in templates]
files = [template[0] for template in templates]
if get_cms_setting('TEMPLATE_INHERITANCE'):
original_labels.append(force_str(_('Inherit the template of the nearest ancestor')))
original_files.append(constants.TEMPLATE_INHERITANCE_MAGIC)
self.assertEqual(set(labels), set(original_labels))
self.assertEqual(set(files), set(original_files))
mod = None
try:
mod = SourceFileLoader("mod", config_path).load_module()
except FileNotFoundError:
print(f"file not found at {config_path}")
except Exception as e:
print(f"An error occurred: {e}")
if mod:
original_labels = [force_str(_(template[1])) for template in mod.TEMPLATES.items()]
original_files = [os.path.join(PATH_PREFIX, template[0].strip()) for template in mod.TEMPLATES.items()]
templates = get_cms_setting('TEMPLATES')
self.assertEqual(len(templates), 3)
labels = [force_str(template[1]) for template in templates]
files = [template[0] for template in templates]
if get_cms_setting('TEMPLATE_INHERITANCE'):
original_labels.append(force_str(_('Inherit the template of the nearest ancestor')))
original_files.append(constants.TEMPLATE_INHERITANCE_MAGIC)
self.assertEqual(set(labels), set(original_labels))
self.assertEqual(set(files), set(original_files))

@override_settings(CMS_TEMPLATES_DIR=GOOD_PATH)
def test_custom_templates_loading(self):
Expand Down
4 changes: 2 additions & 2 deletions cms/tests/test_toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,13 +989,13 @@ def test_toolbar_logout_redirect(self):
response = self.client.get(page3_edit_url)
< 67E6 /td> toolbar = response.context['request'].toolbar
admin_menu = toolbar.get_or_create_menu(ADMIN_MENU_IDENTIFIER)
self.assertEquals(admin_menu.find_first(AjaxItem, name=menu_name).item.on_success, '/')
self.assertEqual(admin_menu.find_first(AjaxItem, name=menu_name).item.on_success, '/')

# Published page with view permissions, redirect
response = self.client.get(page4_edit_url)
toolbar = response.context['request'].toolbar
admin_menu = toolbar.get_or_create_menu(ADMIN_MENU_IDENTIFIER)
self.assertEquals(admin_menu.find_first(AjaxItem, name=menu_name).item.on_success, '/')
self.assertEqual(admin_menu.find_first(AjaxItem, name=menu_name).item.on_success, '/')


@override_settings(ROOT_URLCONF='cms.test_utils.project.placeholderapp_urls')
Expand Down
2 changes: 1 addition & 1 deletion cms/utils/apphook_reload.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import uuid

# Py2 and Py3 compatible reload
from imp import reload
from importlib import reload
from threading import local

from django.conf import settings
Expand Down
5 changes: 2 additions & 3 deletions cms/utils/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ def _load_from_file(module_path):
"""
Load a python module from its absolute filesystem path
"""
from imp import PY_SOURCE, load_module
from importlib.machinery import SourceFileLoader

imported = None
if module_path:
with open(module_path, 'r') as openfile:
imported = load_module("mod", openfile, module_path, ('imported', 'r', PY_SOURCE))
imported = SourceFileLoader("mod", module_path).load_module()
return imported


Expand Down
0