Skip to content

Commit 84fbaad

Browse files
razor-xseambotandrii-balitskyi
authored
test: Retry connection errors in tests using fake (#95)
* Wait 1 second for fake to start in tests * Use retry instead of sleep * ci: Generate code * Update conftest.py * Update test/conftest.py Co-authored-by: Andrii Balitskyi <84702959+andrii-balitskyi@users.noreply.github.com> * Update test/conftest.py Co-authored-by: Andrii Balitskyi <84702959+andrii-balitskyi@users.noreply.github.com> --------- Co-authored-by: Seam Bot <devops@getseam.com> Co-authored-by: Andrii Balitskyi <84702959+andrii-balitskyi@users.noreply.github.com>
1 parent 219c3b5 commit 84fbaad

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

test/conftest.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import socket
22
from urllib.parse import urljoin
3+
from urllib3.util import Retry
34
import pytest
45
import subprocess
5-
import time
66
import os
77
from contextlib import contextmanager
8-
import niquests as requests
8+
from niquests import Session
99
from seam import Seam
1010

1111

@@ -15,12 +15,8 @@ def server():
1515
os.environ["PORT"] = str(port)
1616

1717
with subprocess_popen(["npm", "run", "start"]):
18-
# Allow some time for the server to start
19-
time.sleep(0.5)
20-
2118
endpoint = f"http://localhost:{port}"
2219
seed = get_seed(endpoint)
23-
2420
yield endpoint, seed
2521

2622

@@ -53,5 +49,7 @@ def subprocess_popen(*args):
5349

5450

5551
def get_seed(endpoint):
52+
retries = Retry(connect=5, total=None, backoff_factor=0.1)
53+
session = Session(retries=retries)
5654
seed_url = urljoin(endpoint, "/_fake/default_seed")
57-
return requests.get(seed_url).json()
55+
return session.get(seed_url).json()

0 commit comments

Comments
 (0)