Merge pull request #325600 from erictapen/python-python-redis-lock

python3Packages.python-redis-lock: fix tests for django support
This commit is contained in:
Martin Weinelt 2024-07-17 21:19:02 +02:00 committed by GitHub
commit ff0584e9ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -12,7 +12,6 @@
pytestCheckHook, pytestCheckHook,
pythonOlder, pythonOlder,
redis, redis,
withDjango ? false,
django-redis, django-redis,
}: }:
@ -21,7 +20,6 @@ buildPythonPackage rec {
version = "4.0.0"; version = "4.0.0";
pyproject = true; pyproject = true;
build-system = [ setuptools ];
disabled = pythonOlder "3.7"; disabled = pythonOlder "3.7";
@ -30,16 +28,26 @@ buildPythonPackage rec {
hash = "sha256-Sr0Lz0kTasrWZye/VIbdJJQHjKVeSe+mk/eUB3MZCRo="; hash = "sha256-Sr0Lz0kTasrWZye/VIbdJJQHjKVeSe+mk/eUB3MZCRo=";
}; };
# Fix django tests
postPatch = ''
substituteInPlace tests/test_project/settings.py \
--replace "USE_L10N = True" ""
'';
patches = [ patches = [
# https://github.com/ionelmc/python-redis-lock/pull/119
(fetchpatch { (fetchpatch {
url = "https://github.com/ionelmc/python-redis-lock/pull/119.diff"; url = "https://github.com/ionelmc/python-redis-lock/commit/ae404b7834990b833c1f0f703ec8fbcfecd201c2.patch";
hash = "sha256-Fo43+pCtnrEMxMdEEdo0YfJGkBlhhH0GjYNgpZeHF3U="; hash = "sha256-Fo43+pCtnrEMxMdEEdo0YfJGkBlhhH0GjYNgpZeHF3U=";
}) })
./test_signal_expiration_increase_sleep.patch ./test_signal_expiration_increase_sleep.patch
]; ];
dependencies = [ redis ] ++ lib.optionals withDjango [ django-redis ]; build-system = [ setuptools ];
dependencies = [ redis ];
optional-dependencies.django = [ django-redis ];
nativeCheckInputs = [ nativeCheckInputs = [
eventlet eventlet
@ -47,18 +55,16 @@ buildPythonPackage rec {
pytestCheckHook pytestCheckHook
process-tests process-tests
pkgs.redis pkgs.redis
]; ] ++ optional-dependencies.django;
disabledTests = # For Django tests
[ preCheck = "export DJANGO_SETTINGS_MODULE=test_project.settings";
# https://github.com/ionelmc/python-redis-lock/issues/86
"test_no_overlap2" disabledTests = lib.optionals stdenv.isDarwin [
] # fail on Darwin because it defaults to multiprocessing `spawn`
++ lib.optionals stdenv.isDarwin [ "test_reset_signalizes"
# fail on Darwin because it defaults to multiprocessing `spawn` "test_reset_all_signalizes"
"test_reset_signalizes" ];
"test_reset_all_signalizes"
];
pythonImportsCheck = [ "redis_lock" ]; pythonImportsCheck = [ "redis_lock" ];
@ -67,6 +73,6 @@ buildPythonPackage rec {
description = "Lock context manager implemented via redis SETNX/BLPOP"; description = "Lock context manager implemented via redis SETNX/BLPOP";
homepage = "https://github.com/ionelmc/python-redis-lock"; homepage = "https://github.com/ionelmc/python-redis-lock";
license = licenses.bsd2; license = licenses.bsd2;
maintainers = with maintainers; [ vanschelven ]; maintainers = with maintainers; [ erictapen ];
}; };
} }