Skip to content

Commit 098484f

Browse files
author
Roman
committed
update test_axon.py
1 parent 642c4ec commit 098484f

File tree

1 file changed

+1
-46
lines changed

1 file changed

+1
-46
lines changed

tests/unit_tests/test_axon.py

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
import re
2-
import threading
32
import time
43
from dataclasses import dataclass
54
from typing import Any, Optional, Tuple
65
from unittest import IsolatedAsyncioTestCase
76
from unittest.mock import AsyncMock, MagicMock, patch
87

9-
import aiohttp
108
import fastapi
119
import netaddr
1210
import pydantic
1311
import pytest
14-
import uvicorn
1512
from fastapi.testclient import TestClient
1613
from starlette.requests import Request
1714

18-
from bittensor.core.axon import Axon, AxonMiddleware, FastAPIThreadedServer
15+
from bittensor.core.axon import AxonMiddleware, Axon
1916
from bittensor.core.errors import RunException
2017
from bittensor.core.settings import version_as_int
2118
from bittensor.core.stream import StreamingSynapse
@@ -768,45 +765,3 @@ async def forward_fn(synapse: streaming_synapse_cls):
768765
"computed_body_hash": "a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a",
769766
},
770767
)
771-
772-
773-
@pytest.mark.asyncio
774-
async def test_threaded_fastapi():
775-
server_started = threading.Event()
776-
server_stopped = threading.Event()
777-
778-
async def lifespan(app):
779-
server_started.set()
780-
yield
781-
server_stopped.set()
782-
783-
app = fastapi.FastAPI(
784-
lifespan=lifespan,
785-
)
786-
app.get("/")(lambda: "Hello World")
787-
788-
server = FastAPIThreadedServer(
789-
uvicorn.Config(
790-
app,
791-
),
792-
)
793-
server.start()
794-
795-
server_started.wait()
796-
797-
assert server.is_running is True
798-
799-
async with aiohttp.ClientSession(
800-
base_url="http://127.0.0.1:8000",
801-
) as session:
802-
async with session.get("/") as response:
803-
assert await response.text() == '"Hello World"'
804-
805-
server.stop()
806-
807-
assert server.should_exit is True
808-
809-
server_stopped.wait()
810-
811-
with pytest.raises(aiohttp.ClientConnectorError):
812-
await session.get("/")

0 commit comments

Comments
 (0)