at 23.11-beta 2.0 kB view raw
1{ lib 2, buildPythonPackage 3, fetchPypi 4, pythonOlder 5, stdenv 6 7# build-system 8, hatchling 9 10# dependencies 11, decorator 12, httptools 13, python-magic 14, urllib3 15 16# optional-dependencies 17, xxhash 18, pook 19 20# tests 21, aiohttp 22, asgiref 23, fastapi 24, gevent 25, httpx 26, pytest-asyncio 27, pytestCheckHook 28, redis 29, redis-server 30, requests 31, sure 32 33}: 34 35buildPythonPackage rec { 36 pname = "mocket"; 37 version = "3.12.0"; 38 pyproject = true; 39 40 src = fetchPypi { 41 inherit pname version; 42 hash = "sha256-brvBWwTWT2F/usVBRr7wz9L0kct4X1Fddl4mu5LUENA="; 43 }; 44 45 nativeBuildInputs = [ 46 hatchling 47 ]; 48 49 propagatedBuildInputs = [ 50 decorator 51 httptools 52 python-magic 53 urllib3 54 ]; 55 56 passthru.optional-dependencies = { 57 pook = [ 58 pook 59 ]; 60 speedups = [ 61 xxhash 62 ]; 63 }; 64 65 nativeCheckInputs = [ 66 asgiref 67 fastapi 68 gevent 69 httpx 70 pytest-asyncio 71 pytestCheckHook 72 redis 73 requests 74 sure 75 ] ++ lib.optionals (pythonOlder "3.12") [ 76 aiohttp 77 ] ++ lib.flatten (builtins.attrValues passthru.optional-dependencies); 78 79 preCheck = lib.optionalString stdenv.isLinux '' 80 ${redis-server}/bin/redis-server & 81 REDIS_PID=$! 82 ''; 83 84 postCheck = lib.optionalString stdenv.isLinux '' 85 kill $REDIS_PID 86 ''; 87 88 # Skip http tests, they require network access 89 env.SKIP_TRUE_HTTP = true; 90 91 _darwinAllowLocalNetworking = true; 92 93 disabledTests = [ 94 # tests that require network access (like DNS lookups) 95 "test_truesendall_with_dump_from_recording" 96 "test_asyncio_record_replay" 97 "test_gethostbyname" 98 ]; 99 100 disabledTestPaths = lib.optionals stdenv.isDarwin [ 101 "tests/main/test_redis.py" 102 ]; 103 104 pythonImportsCheck = [ 105 "mocket" 106 ]; 107 108 meta = with lib; { 109 changelog = "https://github.com/mindflayer/python-mocket/releases/tag/${version}"; 110 description = "A socket mock framework for all kinds of sockets including web-clients"; 111 homepage = "https://github.com/mindflayer/python-mocket"; 112 license = licenses.bsd3; 113 maintainers = with maintainers; [ hexa ]; 114 }; 115}