From b95c7d8f21d460101241c8aabe7d3f5350954d75 Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Tue, 11 Aug 2026 23:26:10 +0100 Subject: [PATCH] tests: add precondition for test_recursive_deep This can fail during local test runs (wasn't an issue on github ci), and error is confusing otherwise. This can be caused by sqlalchemy connection pooling, but considering we're moving away from sqlalchemy, just add this for now. --- src/cachew/tests/test_cachew.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/cachew/tests/test_cachew.py b/src/cachew/tests/test_cachew.py index 4d0e2ed..abcb751 100644 --- a/src/cachew/tests/test_cachew.py +++ b/src/cachew/tests/test_cachew.py @@ -1359,6 +1359,16 @@ def factorials(n: int) -> Iterable[int]: def test_recursive_deep(tmp_path: Path) -> None: + if settings.DEFAULT_BACKEND == 'sqlite' and sys.platform != 'win32': + import resource + + soft_limit, hard_limit = resource.getrlimit(resource.RLIMIT_NOFILE) + required_soft_limit = 2048 + assert soft_limit == resource.RLIM_INFINITY or soft_limit >= required_soft_limit, ( + f'test_recursive_deep[sqlite] requires an open-file soft limit of at least {required_soft_limit}; ' + f'got soft={soft_limit}, hard={hard_limit}. Run `ulimit -Sn {required_soft_limit}` before the tests.' + ) + @cachew(tmp_path) def numbers(n: int) -> Iterable[int]: if n == 0: