From 1df869716369d4c178bec55e2fdb099826ac968f Mon Sep 17 00:00:00 2001 From: Kerstin Humm Date: Thu, 4 Jul 2024 16:01:17 +0200 Subject: [PATCH] python3Packages.python-redis-locks: fix tests for django support Also remove a skipped test that just seems to work Remove maintainer, as they asked for it here: https://github.com/NixOS/nixpkgs/pull/212270#issuecomment-1400459355 Co-authored-by: Sandro --- .../python-redis-lock/default.nix | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/pkgs/development/python-modules/python-redis-lock/default.nix b/pkgs/development/python-modules/python-redis-lock/default.nix index b89a7534a2ab4..bca7ec7225d31 100644 --- a/pkgs/development/python-modules/python-redis-lock/default.nix +++ b/pkgs/development/python-modules/python-redis-lock/default.nix @@ -12,7 +12,6 @@ pytestCheckHook, pythonOlder, redis, - withDjango ? false, django-redis, }: @@ -21,7 +20,6 @@ buildPythonPackage rec { version = "4.0.0"; pyproject = true; - build-system = [ setuptools ]; disabled = pythonOlder "3.7"; @@ -30,16 +28,26 @@ buildPythonPackage rec { hash = "sha256-Sr0Lz0kTasrWZye/VIbdJJQHjKVeSe+mk/eUB3MZCRo="; }; + # Fix django tests + postPatch = '' + substituteInPlace tests/test_project/settings.py \ + --replace "USE_L10N = True" "" + ''; + patches = [ + # https://github.com/ionelmc/python-redis-lock/pull/119 (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="; }) - ./test_signal_expiration_increase_sleep.patch ]; - dependencies = [ redis ] ++ lib.optionals withDjango [ django-redis ]; + build-system = [ setuptools ]; + + dependencies = [ redis ]; + + optional-dependencies.django = [ django-redis ]; nativeCheckInputs = [ eventlet @@ -47,18 +55,16 @@ buildPythonPackage rec { pytestCheckHook process-tests pkgs.redis - ]; + ] ++ optional-dependencies.django; - disabledTests = - [ - # https://github.com/ionelmc/python-redis-lock/issues/86 - "test_no_overlap2" - ] - ++ lib.optionals stdenv.isDarwin [ - # fail on Darwin because it defaults to multiprocessing `spawn` - "test_reset_signalizes" - "test_reset_all_signalizes" - ]; + # For Django tests + preCheck = "export DJANGO_SETTINGS_MODULE=test_project.settings"; + + disabledTests = lib.optionals stdenv.isDarwin [ + # fail on Darwin because it defaults to multiprocessing `spawn` + "test_reset_signalizes" + "test_reset_all_signalizes" + ]; pythonImportsCheck = [ "redis_lock" ]; @@ -67,6 +73,6 @@ buildPythonPackage rec { description = "Lock context manager implemented via redis SETNX/BLPOP"; homepage = "https://github.com/ionelmc/python-redis-lock"; license = licenses.bsd2; - maintainers = with maintainers; [ vanschelven ]; + maintainers = with maintainers; [ erictapen ]; }; }