Skip to content

Commit

Permalink
fix: define django_app_config if django version < 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielVZ96 committed Oct 25, 2023
1 parent ccc7ab6 commit 7893518
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
5 changes: 4 additions & 1 deletion completion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Completion App
"""

import django

__version__ = '4.4.0'

default_app_config = 'completion.apps.CompletionAppConfig' # pylint: disable=invalid-name
if django.VERSION < (3, 2):
default_app_config = 'completion.apps.CompletionAppConfig' # pylint: disable=invalid-name
22 changes: 22 additions & 0 deletions completion/tests/test_compatibility.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""
Test compatibility with multiple django versions.
"""
import unittest

import django
from django.test import TestCase

import completion

class TestDefaultAppConfig(TestCase):
"""
Test that default_app_config is only defined if Django version is <3.2
"""

@unittest.skipIf(django.VERSION < (3, 2), "default_app_config is defined by django")
def test_not_defined(self):
self.assertFalse(hasattr(completion, "default_app_config"))

@unittest.skipIf(django.VERSION >= (3, 2), "default_app_config is not defined by django versions higher than 3.2")
def test_defined(self):
self.assertTrue(hasattr(completion, "default_app_config"))

0 comments on commit 7893518

Please sign in to comment.