From 2c1236106d0c8043219a159d41aa3dce5cc84a75 Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Mon, 17 Oct 2022 19:27:26 +0200 Subject: [PATCH] Fix DeprecationWarning about default_app_config in Django 3.2 --- CHANGELOG.rst | 1 + cas_server/__init__.py | 6 ++++-- cas_server/tests/test_utils.py | 10 ++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index d58de00..da43049 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -16,6 +16,7 @@ Added Fixes ----- * Fix unicode sandwich issue in cas_server.utils.update_url +* Fix DeprecationWarning about default_app_config in Django 3.2 Removed ------- diff --git a/cas_server/__init__.py b/cas_server/__init__.py index 2ac3122..d2ae852 100644 --- a/cas_server/__init__.py +++ b/cas_server/__init__.py @@ -9,9 +9,11 @@ # # (c) 2015-2016 Valentin Samir """A django CAS server application""" +import django #: version of the application VERSION = '1.3.1' -#: path the the application configuration class -default_app_config = 'cas_server.apps.CasAppConfig' +if django.VERSION < (3, 2): + #: path the the application configuration class + default_app_config = 'cas_server.apps.CasAppConfig' diff --git a/cas_server/tests/test_utils.py b/cas_server/tests/test_utils.py index 3064abf..d690724 100644 --- a/cas_server/tests/test_utils.py +++ b/cas_server/tests/test_utils.py @@ -10,6 +10,7 @@ # # (c) 2016 Valentin Samir """Tests module for utils""" +import django from django.test import TestCase, RequestFactory from django.db import connection @@ -173,10 +174,11 @@ class UtilsTestCase(TestCase): utils.import_attr('cas_server.utils.toto') with self.assertRaises(ValueError): utils.import_attr('toto') - self.assertEqual( - utils.import_attr('cas_server.default_app_config'), - 'cas_server.apps.CasAppConfig' - ) + if django.VERSION < (3, 2): + self.assertEqual( + utils.import_attr('cas_server.default_app_config'), + 'cas_server.apps.CasAppConfig' + ) self.assertEqual(utils.import_attr(utils), utils) def test_update_url(self):