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