From 74b8bb2cab3fc3493b2c5bdad4303467b00f4802 Mon Sep 17 00:00:00 2001 From: Jonathan Willitts Date: Thu, 29 Apr 2021 12:20:18 +0100 Subject: [PATCH] Update to support test SECRET_KEY generation when running Django <1.10 tests Still uses same char set and length of keys generated that Django get_random_secret_key() does. Not that important since only used for testing anyway. --- tests/conftest.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 565bee2..e699050 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,5 +1,7 @@ +import random + from django.conf import settings -from django.core.management.utils import get_random_secret_key + def pytest_configure(): settings.configure( @@ -34,5 +36,8 @@ def pytest_configure(): ], }, }], - SECRET_KEY=get_random_secret_key() + SECRET_KEY=''.join( + random.choice("abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)") + for _ in range(50) + ), )