Skip to content

Commit 8bc993c

Browse files
authored
Fixing flaky test test_cli_can_build_and_search_index by retrying (#816)
1 parent f0e87e6 commit 8bc993c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tests/test_cli.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import os
22
import sys
3+
import zlib
34
from pathlib import Path
45

56
import pytest
7+
from tenacity import Retrying, retry_if_exception_type, stop_after_attempt
68

79
from paperqa import Docs
810
from paperqa.settings import Settings
@@ -76,7 +78,13 @@ def test_cli_can_build_and_search_index(
7678
settings.agent.index.paper_directory = rel_path_home_to_stub_data
7779
settings.agent.index.index_directory = agent_index_dir
7880
index_name = "test"
79-
build_index(index_name, stub_data_dir, settings)
81+
for attempt in Retrying(
82+
stop=stop_after_attempt(3),
83+
# zlib.error: Error -5 while decompressing data: incomplete or truncated stream
84+
retry=retry_if_exception_type(zlib.error),
85+
):
86+
with attempt:
87+
build_index(index_name, stub_data_dir, settings)
8088
result = search_query("XAI", index_name, settings)
8189
assert len(result) == 1
8290
assert isinstance(result[0][0], Docs)

0 commit comments

Comments
 (0)