Skip to content

Commit 7154fef

Browse files
committed
Better testing maybe
1 parent 914ee4a commit 7154fef

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

.github/workflows/unit-and-integration-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ jobs:
4848
PYTHONUNBUFFERED: "1"
4949
run: |
5050
source venv/bin/activate
51-
python -m uv run pytest tests/unit_tests/ --reruns 3
51+
python -m uv run pytest tests/unit_tests/ --reruns 3 -s
5252
5353
- name: Integration tests
5454
timeout-minutes: 20
5555
env:
5656
PYTHONUNBUFFERED: "1"
5757
run: |
5858
source venv/bin/activate
59-
python -m uv run pytest tests/integration_tests/ --reruns 3
59+
python -m uv run pytest tests/integration_tests/ --reruns 3 -s

tests/integration_tests/test_async_substrate_interface.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os.path
44
import time
55
import threading
6+
import socket
67

78
import bittensor_wallet
89
import pytest
@@ -197,6 +198,13 @@ async def test_query_map_with_odd_number_of_params():
197198

198199
@pytest.mark.asyncio
199200
async def test_improved_reconnection():
201+
def get_free_port():
202+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
203+
s.bind(('', 0)) # Bind to port 0 = OS picks free port
204+
s.listen(1)
205+
port_ = s.getsockname()[1]
206+
return port_
207+
200208
print("Testing test_improved_reconnection")
201209
ws_logger_path = "/tmp/websockets-proxy-test"
202210
ws_logger = logging.getLogger("websockets.proxy")
@@ -210,7 +218,8 @@ async def test_improved_reconnection():
210218
os.remove(asi_logger_path)
211219
logger.setLevel(logging.DEBUG)
212220
logger.addHandler(logging.FileHandler(asi_logger_path))
213-
port = 8079
221+
port = get_free_port()
222+
print(f"Testing using server on port {port}")
214223
proxy = ProxyServer("wss://archive.sub.latent.to", 10, 20, port=port)
215224

216225
server_thread = threading.Thread(target=proxy.connect_and_serve, daemon=True)

0 commit comments

Comments
 (0)