2024-06-05 15:53:02 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
buildPythonPackage,
|
|
|
|
fetchPypi,
|
|
|
|
pythonOlder,
|
|
|
|
stdenv,
|
|
|
|
|
|
|
|
# build-system
|
|
|
|
hatchling,
|
|
|
|
|
|
|
|
# dependencies
|
|
|
|
decorator,
|
|
|
|
httptools,
|
|
|
|
python-magic,
|
|
|
|
urllib3,
|
|
|
|
|
|
|
|
# optional-dependencies
|
|
|
|
xxhash,
|
|
|
|
pook,
|
|
|
|
|
|
|
|
# tests
|
|
|
|
aiohttp,
|
|
|
|
asgiref,
|
|
|
|
fastapi,
|
|
|
|
gevent,
|
|
|
|
httpx,
|
|
|
|
psutil,
|
|
|
|
pytest-asyncio,
|
|
|
|
pytestCheckHook,
|
|
|
|
redis,
|
|
|
|
redis-server,
|
|
|
|
requests,
|
|
|
|
sure,
|
2023-11-16 04:20:00 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
}:
|
2020-08-20 17:08:02 +00:00
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "mocket";
|
2024-05-15 15:35:15 +00:00
|
|
|
version = "3.12.5";
|
2023-11-16 04:20:00 +00:00
|
|
|
pyproject = true;
|
2020-08-20 17:08:02 +00:00
|
|
|
|
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
2024-05-15 15:35:15 +00:00
|
|
|
hash = "sha256-6yWo7SBlVldK+AxUBnQOXjQBxz9HbIC+Ch977xiZxek=";
|
2020-08-20 17:08:02 +00:00
|
|
|
};
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
nativeBuildInputs = [ hatchling ];
|
2023-11-16 04:20:00 +00:00
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
decorator
|
2023-03-04 12:14:45 +00:00
|
|
|
httptools
|
2022-05-18 14:49:53 +00:00
|
|
|
python-magic
|
2020-08-20 17:08:02 +00:00
|
|
|
urllib3
|
2021-03-09 03:18:52 +00:00
|
|
|
];
|
2020-08-20 17:08:02 +00:00
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
passthru.optional-dependencies = {
|
2024-06-05 15:53:02 +00:00
|
|
|
pook = [ pook ];
|
|
|
|
speedups = [ xxhash ];
|
2023-03-04 12:14:45 +00:00
|
|
|
};
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
nativeCheckInputs =
|
|
|
|
[
|
|
|
|
asgiref
|
|
|
|
fastapi
|
|
|
|
gevent
|
|
|
|
httpx
|
|
|
|
psutil
|
|
|
|
pytest-asyncio
|
|
|
|
pytestCheckHook
|
|
|
|
redis
|
|
|
|
requests
|
|
|
|
sure
|
|
|
|
]
|
|
|
|
++ lib.optionals (pythonOlder "3.12") [ aiohttp ]
|
|
|
|
++ lib.flatten (builtins.attrValues passthru.optional-dependencies);
|
2021-02-05 17:12:51 +00:00
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
preCheck = lib.optionalString stdenv.isLinux ''
|
|
|
|
${redis-server}/bin/redis-server &
|
|
|
|
REDIS_PID=$!
|
|
|
|
'';
|
2023-03-04 12:14:45 +00:00
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
postCheck = lib.optionalString stdenv.isLinux ''
|
|
|
|
kill $REDIS_PID
|
|
|
|
'';
|
|
|
|
|
|
|
|
# Skip http tests, they require network access
|
|
|
|
env.SKIP_TRUE_HTTP = true;
|
|
|
|
|
|
|
|
_darwinAllowLocalNetworking = true;
|
2021-02-05 17:12:51 +00:00
|
|
|
|
|
|
|
disabledTests = [
|
|
|
|
# tests that require network access (like DNS lookups)
|
|
|
|
"test_truesendall_with_dump_from_recording"
|
2021-03-09 03:18:52 +00:00
|
|
|
"test_asyncio_record_replay"
|
2022-10-30 15:09:59 +00:00
|
|
|
"test_gethostbyname"
|
2024-04-21 15:54:59 +00:00
|
|
|
# httpx read failure
|
|
|
|
"test_no_dangling_fds"
|
2021-02-05 17:12:51 +00:00
|
|
|
];
|
2020-08-20 17:08:02 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
disabledTestPaths = lib.optionals stdenv.isDarwin [ "tests/main/test_redis.py" ];
|
2023-11-16 04:20:00 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
pythonImportsCheck = [ "mocket" ];
|
2020-08-20 17:08:02 +00:00
|
|
|
|
|
|
|
meta = with lib; {
|
2023-11-16 04:20:00 +00:00
|
|
|
changelog = "https://github.com/mindflayer/python-mocket/releases/tag/${version}";
|
2023-03-04 12:14:45 +00:00
|
|
|
description = "A socket mock framework for all kinds of sockets including web-clients";
|
2020-08-20 17:08:02 +00:00
|
|
|
homepage = "https://github.com/mindflayer/python-mocket";
|
|
|
|
license = licenses.bsd3;
|
2024-01-13 08:15:51 +00:00
|
|
|
maintainers = with maintainers; [ ];
|
2020-08-20 17:08:02 +00:00
|
|
|
};
|
|
|
|
}
|