From f8208af7064435558865181fd084bff2e3080930 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Hubscher?= Date: Tue, 21 Oct 2025 10:23:38 +0200 Subject: [PATCH 1/3] Fix imports --- tests/test_cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 70c5059..1cc8c0a 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -10,8 +10,8 @@ from django.test import TransactionTestCase, override_settings from django.utils import timezone from django.utils.encoding import smart_str -from constance.models import Constance from constance import config +from constance.models import Constance class CliTestCase(TransactionTestCase): From 27b12631198adb9f1b9b39443827b2f7f02430d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Hubscher?= Date: Tue, 21 Oct 2025 10:24:49 +0200 Subject: [PATCH 2/3] Fix formatting --- constance/management/commands/constance.py | 4 ++-- tests/test_cli.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/constance/management/commands/constance.py b/constance/management/commands/constance.py index e226026..b6b4b2c 100644 --- a/constance/management/commands/constance.py +++ b/constance/management/commands/constance.py @@ -70,8 +70,8 @@ class Command(BaseCommand): for k, v in get_values().items(): self.stdout.write(f"{k}\t{v}", ending="\n") elif command == self.REMOVE_STALE_KEYS: - prefix = getattr(settings, 'CONSTANCE_DATABASE_PREFIX', '') - actual_keys = [f'{prefix}{key}' for key in settings.CONSTANCE_CONFIG] + prefix = getattr(settings, "CONSTANCE_DATABASE_PREFIX", "") + actual_keys = [f"{prefix}{key}" for key in settings.CONSTANCE_CONFIG] stale_records = Constance.objects.exclude(key__in=actual_keys) if stale_records: self.stdout.write("The following record will be deleted:", ending="\n") diff --git a/tests/test_cli.py b/tests/test_cli.py index 1cc8c0a..db022f2 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -120,13 +120,13 @@ class CliTestCase(TransactionTestCase): self.assertEqual(Constance.objects.count(), initial_count, msg=self.out) @override_settings( - CONSTANCE_DATABASE_PREFIX='constance:', + CONSTANCE_DATABASE_PREFIX="constance:", ) def test_delete_stale_records_respects_prefix(self): self._populate_database_with_default_values() initial_count = Constance.objects.count() - call_command('constance', 'remove_stale_keys', stdout=self.out) + call_command("constance", "remove_stale_keys", stdout=self.out) self.assertEqual(Constance.objects.count(), initial_count, msg=self.out) @@ -136,4 +136,4 @@ class CliTestCase(TransactionTestCase): in settings since that's not done automatically at startup """ for key, (value, *_) in settings.CONSTANCE_CONFIG.items(): - Constance.objects.create(key=f'{getattr(settings, "CONSTANCE_DATABASE_PREFIX", "")}{key}', value=value) + Constance.objects.create(key=f"{getattr(settings, 'CONSTANCE_DATABASE_PREFIX', '')}{key}", value=value) From 0f74be90354ad8ea6ccd864fc3b6076d23482736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Hubscher?= Date: Tue, 21 Oct 2025 10:28:35 +0200 Subject: [PATCH 3/3] Fix linter --- tests/test_cli.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index db022f2..9328c52 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -6,7 +6,8 @@ from textwrap import dedent from django.conf import settings from django.core.management import CommandError from django.core.management import call_command -from django.test import TransactionTestCase, override_settings +from django.test import TransactionTestCase +from django.test import override_settings from django.utils import timezone from django.utils.encoding import smart_str @@ -51,12 +52,12 @@ class CliTestCase(TransactionTestCase): ) def test_get(self): - call_command("constance", *("get EMAIL_VALUE".split()), stdout=self.out) + call_command("constance", *(["get", "EMAIL_VALUE"]), stdout=self.out) self.assertEqual(self.out.getvalue().strip(), "test@example.com") def test_set(self): - call_command("constance", *("set EMAIL_VALUE blah@example.com".split()), stdout=self.out) + call_command("constance", *(["set", "EMAIL_VALUE", "blah@example.com"]), stdout=self.out) self.assertEqual(config.EMAIL_VALUE, "blah@example.com")