From eed9ab649a2b7f0fca7dc48c68ef6e87d4451e4a Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Sat, 28 Oct 2023 21:45:56 +0200 Subject: [PATCH] python311Packages.mocket: 3.11.1 -> 3.12.0 https://github.com/mindflayer/python-mocket/releases/tag/3.12.0 Test with redis-server on Linux, reorganize dependencies --- .../python-modules/mocket/default.nix | 86 ++++++++++++------- pkgs/top-level/python-packages.nix | 4 +- 2 files changed, 56 insertions(+), 34 deletions(-) diff --git a/pkgs/development/python-modules/mocket/default.nix b/pkgs/development/python-modules/mocket/default.nix index 49125a286e90..41789a796dd1 100644 --- a/pkgs/development/python-modules/mocket/default.nix +++ b/pkgs/development/python-modules/mocket/default.nix @@ -1,37 +1,51 @@ { lib +, buildPythonPackage +, fetchPypi +, pythonOlder +, stdenv + +# build-system +, hatchling + +# dependencies +, decorator +, httptools +, python-magic +, urllib3 + +# optional-dependencies +, xxhash +, pook + +# tests , aiohttp , asgiref -, buildPythonPackage -, decorator , fastapi -, fetchPypi , gevent -, httptools , httpx -, isPy3k -, pook -, pytest-mock +, pytest-asyncio , pytestCheckHook -, python-magic -, pythonOlder , redis +, redis-server , requests , sure -, urllib3 + }: buildPythonPackage rec { pname = "mocket"; - version = "3.11.1"; - format = "setuptools"; - - disabled = pythonOlder "3.7"; + version = "3.12.0"; + pyproject = true; src = fetchPypi { inherit pname version; - hash = "sha256-sEPLUN9nod4AKYcoCNQZ4FBblUCLCPV1dFOrNC6xDWo="; + hash = "sha256-brvBWwTWT2F/usVBRr7wz9L0kct4X1Fddl4mu5LUENA="; }; + nativeBuildInputs = [ + hatchling + ]; + propagatedBuildInputs = [ decorator httptools @@ -43,52 +57,58 @@ buildPythonPackage rec { pook = [ pook ]; + speedups = [ + xxhash + ]; }; nativeCheckInputs = [ - aiohttp asgiref fastapi gevent httpx - pytest-mock + pytest-asyncio pytestCheckHook redis requests sure - ] ++ passthru.optional-dependencies.pook; + ] ++ lib.optionals (pythonOlder "3.12") [ + aiohttp + ] ++ lib.flatten (builtins.attrValues passthru.optional-dependencies); - # Skip http tests - SKIP_TRUE_HTTP = true; + preCheck = lib.optionalString stdenv.isLinux '' + ${redis-server}/bin/redis-server & + REDIS_PID=$! + ''; - disabledTestPaths = [ - # Requires a live Redis instance - "tests/main/test_redis.py" - ]; + postCheck = lib.optionalString stdenv.isLinux '' + kill $REDIS_PID + ''; + + # Skip http tests, they require network access + env.SKIP_TRUE_HTTP = true; + + _darwinAllowLocalNetworking = true; disabledTests = [ # tests that require network access (like DNS lookups) - "test_truesendall" - "test_truesendall_with_chunk_recording" - "test_truesendall_with_gzip_recording" - "test_truesendall_with_recording" - "test_wrongpath_truesendall" "test_truesendall_with_dump_from_recording" - "test_truesendall_with_recording_https" - "test_truesendall_after_mocket_session" - "test_real_request_session" "test_asyncio_record_replay" "test_gethostbyname" ]; + disabledTestPaths = lib.optionals stdenv.isDarwin [ + "tests/main/test_redis.py" + ]; + pythonImportsCheck = [ "mocket" ]; meta = with lib; { + changelog = "https://github.com/mindflayer/python-mocket/releases/tag/${version}"; description = "A socket mock framework for all kinds of sockets including web-clients"; homepage = "https://github.com/mindflayer/python-mocket"; - changelog = "https://github.com/mindflayer/python-mocket/releases/tag/${version}"; license = licenses.bsd3; maintainers = with maintainers; [ hexa ]; }; diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index c5dfe185aef6..1b7aa8f45639 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -6930,7 +6930,9 @@ self: super: with self; { mobly = callPackage ../development/python-modules/mobly { }; - mocket = callPackage ../development/python-modules/mocket { }; + mocket = callPackage ../development/python-modules/mocket { + redis-server = pkgs.redis; + }; mock = callPackage ../development/python-modules/mock { };