fastapi-testing 0.3.0__tar.gz → 0.3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastapi-testing
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: A lightweight, async-first testing framework for FastAPI applications
5
5
  Project-URL: Homepage, https://github.com/descoped/fastapi-testing
6
6
  Project-URL: Repository, https://github.com/descoped/fastapi-testing
@@ -31,6 +31,12 @@ Description-Content-Type: text/markdown
31
31
 
32
32
  # FastAPI Testing
33
33
 
34
+ [![Build Status](https://github.com/descoped/fastapi-testing/actions/workflows/build-test.yml/badge.svg)](https://github.com/descoped/fastapi-testing/actions/workflows/build-test-native.yml)
35
+ [![Coverage](https://codecov.io/gh/descoped/fastapi-testing/branch/master/graph/badge.svg)](https://codecov.io/gh/descoped/fastapi-testing)
36
+ [![Python Version](https://img.shields.io/badge/python-3.11%2B-blue.svg)](https://www.python.org/downloads/)
37
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
38
+ [![Release](https://img.shields.io/github/v/release/descoped/fastapi-testing)](https://github.com/descoped/fastapi-testing/releases)
39
+
34
40
  A lightweight, async-first testing framework designed specifically for FastAPI applications. This library provides a simple way to write integration tests for FastAPI applications with proper lifecycle management and async support.
35
41
 
36
42
  ## Features
@@ -386,6 +392,38 @@ server = AsyncTestServer(
386
392
  4. Handle exceptions appropriately in your tests
387
393
  5. Use type hints to catch potential issues early
388
394
 
395
+ ## Testing
396
+
397
+ The framework itself is thoroughly tested with >88% code coverage, ensuring reliability for production use.
398
+
399
+ ### Running Tests
400
+
401
+ ```bash
402
+ # Run all tests
403
+ uv run pytest
404
+
405
+ # Run with coverage report
406
+ uv run pytest --cov=src/fastapi_testing --cov-report=term-missing
407
+
408
+ # Run specific test categories
409
+ uv run pytest tests/test_server.py # Server functionality
410
+ uv run pytest tests/test_websockets.py # WebSocket support
411
+ uv run pytest tests/test_config.py # Configuration tests
412
+ ```
413
+
414
+ ### Test Structure
415
+
416
+ The test suite includes:
417
+
418
+ - **Integration tests** - Real FastAPI applications with actual network connections
419
+ - **Configuration tests** - Environment variable loading and validation
420
+ - **Error handling tests** - Edge cases and failure scenarios
421
+ - **WebSocket tests** - Real-time bidirectional communication
422
+ - **Lifecycle tests** - Server startup, shutdown, and resource management
423
+ - **Concurrent request tests** - Multiple simultaneous connections
424
+
425
+ All tests follow modern async/await patterns and avoid mocks to ensure real-world reliability.
426
+
389
427
  ## Error Handling
390
428
 
391
429
  The framework provides clear error messages for common issues:
@@ -1,5 +1,11 @@
1
1
  # FastAPI Testing
2
2
 
3
+ [![Build Status](https://github.com/descoped/fastapi-testing/actions/workflows/build-test.yml/badge.svg)](https://github.com/descoped/fastapi-testing/actions/workflows/build-test-native.yml)
4
+ [![Coverage](https://codecov.io/gh/descoped/fastapi-testing/branch/master/graph/badge.svg)](https://codecov.io/gh/descoped/fastapi-testing)
5
+ [![Python Version](https://img.shields.io/badge/python-3.11%2B-blue.svg)](https://www.python.org/downloads/)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+ [![Release](https://img.shields.io/github/v/release/descoped/fastapi-testing)](https://github.com/descoped/fastapi-testing/releases)
8
+
3
9
  A lightweight, async-first testing framework designed specifically for FastAPI applications. This library provides a simple way to write integration tests for FastAPI applications with proper lifecycle management and async support.
4
10
 
5
11
  ## Features
@@ -355,6 +361,38 @@ server = AsyncTestServer(
355
361
  4. Handle exceptions appropriately in your tests
356
362
  5. Use type hints to catch potential issues early
357
363
 
364
+ ## Testing
365
+
366
+ The framework itself is thoroughly tested with >88% code coverage, ensuring reliability for production use.
367
+
368
+ ### Running Tests
369
+
370
+ ```bash
371
+ # Run all tests
372
+ uv run pytest
373
+
374
+ # Run with coverage report
375
+ uv run pytest --cov=src/fastapi_testing --cov-report=term-missing
376
+
377
+ # Run specific test categories
378
+ uv run pytest tests/test_server.py # Server functionality
379
+ uv run pytest tests/test_websockets.py # WebSocket support
380
+ uv run pytest tests/test_config.py # Configuration tests
381
+ ```
382
+
383
+ ### Test Structure
384
+
385
+ The test suite includes:
386
+
387
+ - **Integration tests** - Real FastAPI applications with actual network connections
388
+ - **Configuration tests** - Environment variable loading and validation
389
+ - **Error handling tests** - Edge cases and failure scenarios
390
+ - **WebSocket tests** - Real-time bidirectional communication
391
+ - **Lifecycle tests** - Server startup, shutdown, and resource management
392
+ - **Concurrent request tests** - Multiple simultaneous connections
393
+
394
+ All tests follow modern async/await patterns and avoid mocks to ensure real-world reliability.
395
+
358
396
  ## Error Handling
359
397
 
360
398
  The framework provides clear error messages for common issues:
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "fastapi-testing"
3
- version = "0.3.0"
3
+ version = "0.3.1"
4
4
  description = "A lightweight, async-first testing framework for FastAPI applications"
5
5
  authors = [
6
6
  { name = "Ove Ranheim", email = "oranheim@gmail.com" }
@@ -37,6 +37,7 @@ dev = [
37
37
  "pytest-asyncio>=0.25.2",
38
38
  "pytest-cov>=6.0.0",
39
39
  "pydantic>=2.10.6",
40
+ "ruff>=0.8.0",
40
41
  "restructuredtext-lint>=1.4.0",
41
42
  "pygments>=2.19.1",
42
43
  ]
@@ -86,3 +87,59 @@ asyncio_default_fixture_loop_scope = "function"
86
87
  markers = [
87
88
  "asyncio: mark test as async",
88
89
  ]
90
+
91
+ [tool.ruff]
92
+ target-version = "py311"
93
+ line-length = 120
94
+ indent-width = 4
95
+ respect-gitignore = true
96
+ extend-exclude = [
97
+ "__pycache__",
98
+ ".pytest_cache",
99
+ "build",
100
+ "dist",
101
+ ".venv",
102
+ ".env",
103
+ "htmlcov",
104
+ ]
105
+
106
+ [tool.ruff.lint]
107
+ select = [
108
+ "E", # pycodestyle errors
109
+ "W", # pycodestyle warnings
110
+ "F", # pyflakes
111
+ "I", # isort
112
+ "N", # pep8-naming
113
+ "UP", # pyupgrade
114
+ "C4", # flake8-comprehensions
115
+ "B", # flake8-bugbear
116
+ "A", # flake8-builtins
117
+ "T20", # flake8-print
118
+ "SIM", # flake8-simplify
119
+ "RUF", # Ruff-specific rules
120
+ ]
121
+ ignore = [
122
+ "E501", # Line too long (handled by formatter)
123
+ "E741", # Ambiguous variable name
124
+ "B008", # Do not perform function calls in argument defaults
125
+ "B017", # Assert raises on Exception - sometimes needed for testing
126
+ "T201", # Print found (allow print statements)
127
+ "RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
128
+ ]
129
+
130
+ [tool.ruff.lint.isort]
131
+ known-first-party = ["fastapi_testing"]
132
+ force-single-line = false
133
+ combine-as-imports = true
134
+ split-on-trailing-comma = true
135
+
136
+ [tool.ruff.lint.pyupgrade]
137
+ keep-runtime-typing = true
138
+
139
+ [tool.ruff.format]
140
+ quote-style = "double"
141
+ indent-style = "space"
142
+ skip-magic-trailing-comma = false
143
+ line-ending = "auto"
144
+ docstring-code-format = true
145
+ docstring-code-line-length = "dynamic"
@@ -2,9 +2,10 @@ import asyncio
2
2
  import json
3
3
  import logging
4
4
  import os
5
- from contextlib import asynccontextmanager
5
+ from collections.abc import AsyncGenerator
6
+ from contextlib import asynccontextmanager, suppress
6
7
  from dataclasses import dataclass
7
- from typing import List, Optional, Any, Set, AsyncGenerator, Dict, Union
8
+ from typing import Any
8
9
 
9
10
  import httpx
10
11
  import uvicorn
@@ -17,7 +18,7 @@ from websockets.protocol import State
17
18
  logger = logging.getLogger(__name__)
18
19
 
19
20
  # Configuration Constants
20
- DEFAULT_WS_MESSAGE_SIZE = 2 ** 20 # 1MB
21
+ DEFAULT_WS_MESSAGE_SIZE = 2**20 # 1MB
21
22
  DEFAULT_WS_QUEUE_SIZE = 32
22
23
  DEFAULT_KEEPALIVE_CONNS = 20
23
24
  DEFAULT_MAX_CONNS = 100
@@ -31,15 +32,15 @@ class Config:
31
32
  """
32
33
 
33
34
  def __init__(
34
- self,
35
- ws_max_message_size: int = DEFAULT_WS_MESSAGE_SIZE,
36
- ws_max_queue_size: int = DEFAULT_WS_QUEUE_SIZE,
37
- http_max_keepalive: int = DEFAULT_KEEPALIVE_CONNS,
38
- http_max_connections: int = DEFAULT_MAX_CONNS,
39
- ws_retry_attempts: int = DEFAULT_WS_RETRY_ATTEMPTS,
40
- ws_retry_delay: float = DEFAULT_WS_RETRY_DELAY,
41
- port_range_start: int = 8001,
42
- port_range_end: int = 9000,
35
+ self,
36
+ ws_max_message_size: int = DEFAULT_WS_MESSAGE_SIZE,
37
+ ws_max_queue_size: int = DEFAULT_WS_QUEUE_SIZE,
38
+ http_max_keepalive: int = DEFAULT_KEEPALIVE_CONNS,
39
+ http_max_connections: int = DEFAULT_MAX_CONNS,
40
+ ws_retry_attempts: int = DEFAULT_WS_RETRY_ATTEMPTS,
41
+ ws_retry_delay: float = DEFAULT_WS_RETRY_DELAY,
42
+ port_range_start: int = 8001,
43
+ port_range_end: int = 9000,
43
44
  ):
44
45
  self.WS_MAX_MESSAGE_SIZE = ws_max_message_size
45
46
  self.WS_MAX_QUEUE_SIZE = ws_max_queue_size
@@ -62,7 +63,7 @@ class Config:
62
63
  # Convert to expected parameter names
63
64
  config_params = {}
64
65
  for env_key, env_value in env_vars.items():
65
- config_key = env_key[len(prefix):].lower()
66
+ config_key = env_key[len(prefix) :].lower()
66
67
  # Handle type conversion
67
68
  if config_key in [
68
69
  "ws_max_message_size",
@@ -71,17 +72,13 @@ class Config:
71
72
  "http_max_connections",
72
73
  "ws_retry_attempts",
73
74
  "port_range_start",
74
- "port_range_end"
75
+ "port_range_end",
75
76
  ]:
76
- try:
77
+ with suppress(ValueError):
77
78
  config_params[config_key] = int(env_value)
78
- except ValueError:
79
- pass # Silently ignore invalid values
80
79
  elif config_key == "ws_retry_delay":
81
- try:
80
+ with suppress(ValueError):
82
81
  config_params[config_key] = float(env_value)
83
- except ValueError:
84
- pass
85
82
 
86
83
  return cls(**config_params)
87
84
 
@@ -104,6 +101,7 @@ global_config = Config()
104
101
 
105
102
  class InvalidResponseTypeError(Exception):
106
103
  """Exception raised when an operation is not supported for the response type."""
104
+
107
105
  pass
108
106
 
109
107
 
@@ -121,38 +119,39 @@ class WebSocketConfig:
121
119
  max_queue: Maximum number of queued messages
122
120
  timeout: Connection timeout in seconds
123
121
  """
124
- subprotocols: Optional[List[str]] = None
125
- compression: Optional[str] = None
126
- extra_headers: Optional[Dict[str, str]] = None
127
- ping_interval: Optional[float] = None
128
- ping_timeout: Optional[float] = None
122
+
123
+ subprotocols: list[str] | None = None
124
+ compression: str | None = None
125
+ extra_headers: dict[str, str] | None = None
126
+ ping_interval: float | None = None
127
+ ping_timeout: float | None = None
129
128
  max_size: int = global_config.WS_MAX_MESSAGE_SIZE
130
129
  max_queue: int = global_config.WS_MAX_QUEUE_SIZE
131
- timeout: Optional[float] = None
130
+ timeout: float | None = None
132
131
 
133
132
 
134
133
  class PortGenerator:
135
- """Manages port allocation for test servers using configuration from global settings.
136
- """
134
+ """Manages port allocation for test servers using configuration from global settings."""
137
135
 
138
- def __init__(self, start: Optional[int] = None, end: Optional[int] = None):
136
+ def __init__(self, start: int | None = None, end: int | None = None):
139
137
  if start is None:
140
138
  start = global_config.PORT_RANGE_START
141
139
  if end is None:
142
140
  end = global_config.PORT_RANGE_END
143
141
  self.start = start
144
142
  self.end = end
145
- self.used_ports: Set[int] = set()
143
+ self.used_ports: set[int] = set()
146
144
 
147
145
  @staticmethod
148
146
  def is_port_available(port: int) -> bool:
149
- from contextlib import closing
150
147
  import socket
148
+ from contextlib import closing
149
+
151
150
  with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
152
151
  try:
153
- sock.bind(('localhost', port))
152
+ sock.bind(("localhost", port))
154
153
  return True
155
- except (socket.error, OverflowError):
154
+ except (OSError, OverflowError):
156
155
  return False
157
156
 
158
157
  def get_port(self) -> int:
@@ -162,6 +161,7 @@ class PortGenerator:
162
161
  raise RuntimeError(f"No available ports in range {self.start}-{self.end}")
163
162
 
164
163
  import random
164
+
165
165
  while available_ports:
166
166
  port = random.choice(list(available_ports))
167
167
  if self.is_port_available(port):
@@ -182,7 +182,7 @@ class AsyncTestResponse:
182
182
  with proper type checking and error handling.
183
183
  """
184
184
 
185
- def __init__(self, response: Union[httpx.Response, ClientConnection]):
185
+ def __init__(self, response: httpx.Response | ClientConnection):
186
186
  self._response = response
187
187
  self._is_websocket = isinstance(response, ClientConnection)
188
188
 
@@ -190,14 +190,16 @@ class AsyncTestResponse:
190
190
  """Get JSON response (HTTP only)."""
191
191
  if self._is_websocket:
192
192
  raise InvalidResponseTypeError(
193
- "Cannot get JSON directly from WebSocket response. Use websocket() methods instead.")
193
+ "Cannot get JSON directly from WebSocket response. Use websocket() methods instead."
194
+ )
194
195
  return await asyncio.to_thread(self._response.json)
195
196
 
196
197
  async def text(self) -> str:
197
198
  """Get text response (HTTP only)."""
198
199
  if self._is_websocket:
199
200
  raise InvalidResponseTypeError(
200
- "Cannot get text directly from WebSocket response. Use websocket() methods instead.")
201
+ "Cannot get text directly from WebSocket response. Use websocket() methods instead."
202
+ )
201
203
  return await asyncio.to_thread(lambda: self._response.text)
202
204
 
203
205
  @property
@@ -213,12 +215,13 @@ class AsyncTestResponse:
213
215
  raise InvalidResponseTypeError("This response is not a WebSocket connection")
214
216
  return self._response
215
217
 
216
- async def expect_status(self, status_code: int) -> 'AsyncTestResponse':
218
+ async def expect_status(self, status_code: int) -> "AsyncTestResponse":
217
219
  """Assert expected status code (HTTP only)."""
218
220
  if self._is_websocket:
219
221
  raise InvalidResponseTypeError("WebSocket connections don't have status codes")
220
- assert self._response.status_code == status_code, \
222
+ assert self._response.status_code == status_code, (
221
223
  f"Expected status {status_code}, got {self._response.status_code}"
224
+ )
222
225
  return self
223
226
 
224
227
 
@@ -272,15 +275,13 @@ class WebSocketHelper:
272
275
 
273
276
  @staticmethod
274
277
  async def expect_message(
275
- resp: AsyncTestResponse,
276
- expected: Union[str, dict, bytes],
277
- timeout: Optional[float] = None
278
+ resp: AsyncTestResponse, expected: str | dict | bytes, timeout: float | None = None
278
279
  ) -> None:
279
280
  """Assert expected message is received within timeout."""
280
281
  ws = resp.websocket()
281
282
  try:
282
283
  message = await asyncio.wait_for(ws.recv(), timeout)
283
- except asyncio.TimeoutError as e:
284
+ except TimeoutError as e:
284
285
  logger.error("Timed out waiting for message")
285
286
  raise e
286
287
 
@@ -294,10 +295,7 @@ class WebSocketHelper:
294
295
  raise AssertionError(f"Expected message {expected}, got {message}")
295
296
 
296
297
  @staticmethod
297
- async def drain_messages(
298
- resp: AsyncTestResponse,
299
- timeout: Optional[float] = 0.1
300
- ) -> List[Any]:
298
+ async def drain_messages(resp: AsyncTestResponse, timeout: float | None = 0.1) -> list[Any]:
301
299
  """Drain all pending messages from websocket queue."""
302
300
  ws = resp.websocket()
303
301
  messages = []
@@ -305,7 +303,7 @@ class WebSocketHelper:
305
303
  while True:
306
304
  message = await asyncio.wait_for(ws.recv(), timeout)
307
305
  messages.append(message)
308
- except asyncio.TimeoutError:
306
+ except TimeoutError:
309
307
  pass
310
308
  return messages
311
309
 
@@ -313,26 +311,17 @@ class WebSocketHelper:
313
311
  class AsyncTestClient:
314
312
  """Async test client supporting both HTTP and WebSocket connections."""
315
313
 
316
- def __init__(
317
- self,
318
- base_url: str,
319
- timeout: float = 30.0,
320
- follow_redirects: bool = True
321
- ):
322
- self._base_url = base_url.rstrip('/')
314
+ def __init__(self, base_url: str, timeout: float = 30.0, follow_redirects: bool = True):
315
+ self._base_url = base_url.rstrip("/")
323
316
  self._timeout = timeout
324
- self._websocket_connections: Set[ClientConnection] = set()
317
+ self._websocket_connections: set[ClientConnection] = set()
325
318
 
326
319
  limits = httpx.Limits(
327
320
  max_keepalive_connections=global_config.HTTP_MAX_KEEPALIVE,
328
- max_connections=global_config.HTTP_MAX_CONNECTIONS
321
+ max_connections=global_config.HTTP_MAX_CONNECTIONS,
329
322
  )
330
323
  self._client = httpx.AsyncClient(
331
- base_url=self._base_url,
332
- timeout=timeout,
333
- follow_redirects=follow_redirects,
334
- limits=limits,
335
- http2=True
324
+ base_url=self._base_url, timeout=timeout, follow_redirects=follow_redirects, limits=limits, http2=True
336
325
  )
337
326
 
338
327
  self.ws = WebSocketHelper()
@@ -354,21 +343,13 @@ class AsyncTestClient:
354
343
  if self._client:
355
344
  await self._client.aclose()
356
345
 
357
- async def request(
358
- self,
359
- method: str,
360
- url: str,
361
- **kwargs: Any
362
- ) -> AsyncTestResponse:
346
+ async def request(self, method: str, url: str, **kwargs: Any) -> AsyncTestResponse:
363
347
  """Make HTTP request."""
364
348
  response = await self._client.request(method, url, **kwargs)
365
349
  return AsyncTestResponse(response)
366
350
 
367
351
  async def websocket(
368
- self,
369
- path: str,
370
- config: Optional[WebSocketConfig] = None,
371
- options: Optional[Dict[str, Any]] = None
352
+ self, path: str, config: WebSocketConfig | None = None, options: dict[str, Any] | None = None
372
353
  ) -> AsyncTestResponse:
373
354
  """Create a websocket connection with configuration."""
374
355
  if not (self._base_url.startswith("http://") or self._base_url.startswith("https://")):
@@ -380,25 +361,25 @@ class AsyncTestClient:
380
361
  else:
381
362
  ws_url = f"ws://{self._base_url}{path}"
382
363
 
383
- connect_kwargs: Dict[str, Any] = {
384
- 'open_timeout': self._timeout,
385
- 'max_size': global_config.WS_MAX_MESSAGE_SIZE,
386
- 'max_queue': global_config.WS_MAX_QUEUE_SIZE
364
+ connect_kwargs: dict[str, Any] = {
365
+ "open_timeout": self._timeout,
366
+ "max_size": global_config.WS_MAX_MESSAGE_SIZE,
367
+ "max_queue": global_config.WS_MAX_QUEUE_SIZE,
387
368
  }
388
369
 
389
370
  if config:
390
371
  if config.subprotocols:
391
- connect_kwargs['subprotocols'] = config.subprotocols
372
+ connect_kwargs["subprotocols"] = config.subprotocols
392
373
  if config.compression:
393
- connect_kwargs['compression'] = config.compression
374
+ connect_kwargs["compression"] = config.compression
394
375
  if config.extra_headers:
395
- connect_kwargs['additional_headers'] = config.extra_headers
376
+ connect_kwargs["additional_headers"] = config.extra_headers
396
377
  if config.ping_interval:
397
- connect_kwargs['ping_interval'] = config.ping_interval
378
+ connect_kwargs["ping_interval"] = config.ping_interval
398
379
  if config.ping_timeout:
399
- connect_kwargs['ping_timeout'] = config.ping_timeout
380
+ connect_kwargs["ping_timeout"] = config.ping_timeout
400
381
  if config.timeout:
401
- connect_kwargs['open_timeout'] = config.timeout
382
+ connect_kwargs["open_timeout"] = config.timeout
402
383
 
403
384
  if options:
404
385
  connect_kwargs.update(options)
@@ -423,19 +404,19 @@ class AsyncTestClient:
423
404
  return AsyncTestResponse(ws)
424
405
 
425
406
  async def get(self, url: str, **kwargs: Any) -> AsyncTestResponse:
426
- return await self.request('GET', url, **kwargs)
407
+ return await self.request("GET", url, **kwargs)
427
408
 
428
409
  async def post(self, url: str, **kwargs: Any) -> AsyncTestResponse:
429
- return await self.request('POST', url, **kwargs)
410
+ return await self.request("POST", url, **kwargs)
430
411
 
431
412
  async def put(self, url: str, **kwargs: Any) -> AsyncTestResponse:
432
- return await self.request('PUT', url, **kwargs)
413
+ return await self.request("PUT", url, **kwargs)
433
414
 
434
415
  async def delete(self, url: str, **kwargs: Any) -> AsyncTestResponse:
435
- return await self.request('DELETE', url, **kwargs)
416
+ return await self.request("DELETE", url, **kwargs)
436
417
 
437
418
  async def patch(self, url: str, **kwargs: Any) -> AsyncTestResponse:
438
- return await self.request('PATCH', url, **kwargs)
419
+ return await self.request("PATCH", url, **kwargs)
439
420
 
440
421
  async def __aenter__(self) -> "AsyncTestClient":
441
422
  return self
@@ -451,7 +432,7 @@ class UvicornTestServer(uvicorn.Server):
451
432
  super().__init__(config)
452
433
  self.startup_handler = startup_handler
453
434
 
454
- async def startup(self, sockets: Optional[List] = None) -> None:
435
+ async def startup(self, sockets: list | None = None) -> None:
455
436
  """Override startup to signal when ready."""
456
437
  await super().startup(sockets=sockets)
457
438
  self.startup_handler.set()
@@ -465,22 +446,22 @@ class AsyncTestServer:
465
446
  """Async test server with proper lifecycle management and WebSocket support."""
466
447
 
467
448
  def __init__(
468
- self,
469
- lifespan: Optional[Lifespan[AppType]] = None,
470
- startup_timeout: float = 30.0,
471
- shutdown_timeout: float = 10.0,
449
+ self,
450
+ lifespan: Lifespan[AppType] | None = None,
451
+ startup_timeout: float = 30.0,
452
+ shutdown_timeout: float = 10.0,
472
453
  ):
473
454
  self.app = FastAPI(lifespan=lifespan)
474
455
  self.startup_timeout = startup_timeout
475
456
  self.shutdown_timeout = shutdown_timeout
476
457
  self._startup_complete = asyncio.Event()
477
458
  self._shutdown_complete = asyncio.Event()
478
- self._server_task: Optional[asyncio.Task] = None
479
- self._port: Optional[int] = None
459
+ self._server_task: asyncio.Task | None = None
460
+ self._port: int | None = None
480
461
  self._host = "127.0.0.1"
481
- self._client: Optional[AsyncTestClient] = None
482
- self._server: Optional[UvicornTestServer] = None
483
- self._websocket_tasks: Set[asyncio.Task] = set()
462
+ self._client: AsyncTestClient | None = None
463
+ self._server: UvicornTestServer | None = None
464
+ self._websocket_tasks: set[asyncio.Task] = set()
484
465
 
485
466
  async def start(self) -> None:
486
467
  """Start the server asynchronously with proper lifecycle management."""
@@ -490,13 +471,7 @@ class AsyncTestServer:
490
471
  self._port = _port_generator.get_port()
491
472
  startup_handler = asyncio.Event()
492
473
 
493
- config = uvicorn.Config(
494
- app=self.app,
495
- host=self._host,
496
- port=self._port,
497
- log_level="error",
498
- loop="asyncio"
499
- )
474
+ config = uvicorn.Config(app=self.app, host=self._host, port=self._port, log_level="error", loop="asyncio")
500
475
 
501
476
  self._server = UvicornTestServer(config=config, startup_handler=startup_handler)
502
477
 
@@ -505,19 +480,14 @@ class AsyncTestServer:
505
480
  try:
506
481
  await asyncio.wait_for(startup_handler.wait(), timeout=self.startup_timeout)
507
482
 
508
- self._client = AsyncTestClient(
509
- base_url=self.base_url,
510
- timeout=self.startup_timeout
511
- )
483
+ self._client = AsyncTestClient(base_url=self.base_url, timeout=self.startup_timeout)
512
484
 
513
485
  self._startup_complete.set()
514
486
 
515
- except (asyncio.TimeoutError, Exception) as e:
487
+ except (TimeoutError, Exception) as e:
516
488
  await self.stop()
517
489
  if isinstance(e, asyncio.TimeoutError):
518
- raise RuntimeError(
519
- f"Server startup timed out on host {self._host} and port {self._port}"
520
- ) from e
490
+ raise RuntimeError(f"Server startup timed out on host {self._host} and port {self._port}") from e
521
491
  raise
522
492
 
523
493
  async def stop(self) -> None:
@@ -543,10 +513,8 @@ class AsyncTestServer:
543
513
 
544
514
  await asyncio.wait_for(self._server_task, timeout=self.shutdown_timeout)
545
515
 
546
- except asyncio.TimeoutError:
547
- logger.error(
548
- f"Timeout waiting for server shutdown on host {self._host} port {self._port}"
549
- )
516
+ except TimeoutError:
517
+ logger.error(f"Timeout waiting for server shutdown on host {self._host} port {self._port}")
550
518
  if not self._server_task.done():
551
519
  self._server_task.cancel()
552
520
  await asyncio.gather(self._server_task, return_exceptions=True)
@@ -567,7 +535,7 @@ class AsyncTestServer:
567
535
  raise RuntimeError("Server is not running")
568
536
  return f"http://{self._host}:{self._port}"
569
537
 
570
- async def __aenter__(self) -> 'AsyncTestServer':
538
+ async def __aenter__(self) -> "AsyncTestServer":
571
539
  await self.start()
572
540
  return self
573
541
 
@@ -583,7 +551,7 @@ class AsyncTestServer:
583
551
 
584
552
  @asynccontextmanager
585
553
  async def create_test_server(
586
- lifespan: Optional[Lifespan[AppType]] = None,
554
+ lifespan: Lifespan[AppType] | None = None,
587
555
  ) -> AsyncGenerator[AsyncTestServer, None]:
588
556
  """Create and manage a TestServer instance with proper lifecycle"""
589
557
  server = AsyncTestServer(lifespan=lifespan)
@@ -1,11 +1,11 @@
1
1
  version = 1
2
- revision = 3
2
+ revision = 2
3
3
  requires-python = ">=3.11"
4
4
 
5
5
  [[package]]
6
6
  name = "annotated-types"
7
7
  version = "0.7.0"
8
- source = { registry = "https://pypi.org/simple/" }
8
+ source = { registry = "https://pypi.org/simple" }
9
9
  sdist = { url = "https://files.pythonhosted.org/packages/ee/67/531ea369ba64dcff5ec9c3402f9f51bf748cec26dde048a2f973a4eea7f5/annotated_types-0.7.0.tar.gz", hash = "sha256:aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89", size = 16081, upload-time = "2024-05-20T21:33:25.928Z" }
10
10
  wheels = [
11
11
  { url = "https://files.pythonhosted.org/packages/78/b6/6307fbef88d9b5ee7421e68d78a9f162e0da4900bc5f5793f6d3d0e34fb8/annotated_types-0.7.0-py3-none-any.whl", hash = "sha256:1f02e8b43a8fbbc3f3e0d4f0f4bfc8131bcb4eebe8849b8e5c773f3a1c582a53", size = 13643, upload-time = "2024-05-20T21:33:24.1Z" },
@@ -14,7 +14,7 @@ wheels = [
14
14
  [[package]]
15
15
  name = "anyio"
16
16
  version = "4.9.0"
17
- source = { registry = "https://pypi.org/simple/" }
17
+ source = { registry = "https://pypi.org/simple" }
18
18
  dependencies = [
19
19
  { name = "idna" },
20
20
  { name = "sniffio" },
@@ -28,7 +28,7 @@ wheels = [
28
28
  [[package]]
29
29
  name = "certifi"
30
30
  version = "2025.7.14"
31
- source = { registry = "https://pypi.org/simple/" }
31
+ source = { registry = "https://pypi.org/simple" }
32
32
  sdist = { url = "https://files.pythonhosted.org/packages/b3/76/52c535bcebe74590f296d6c77c86dabf761c41980e1347a2422e4aa2ae41/certifi-2025.7.14.tar.gz", hash = "sha256:8ea99dbdfaaf2ba2f9bac77b9249ef62ec5218e7c2b2e903378ed5fccf765995", size = 163981, upload-time = "2025-07-14T03:29:28.449Z" }
33
33
  wheels = [
34
34
  { url = "https://files.pythonhosted.org/packages/4f/52/34c6cf5bb9285074dc3531c437b3919e825d976fde097a7a73f79e726d03/certifi-2025.7.14-py3-none-any.whl", hash = "sha256:6b31f564a415d79ee77df69d757bb49a5bb53bd9f756cbbe24394ffd6fc1f4b2", size = 162722, upload-time = "2025-07-14T03:29:26.863Z" },
@@ -37,7 +37,7 @@ wheels = [
37
37
  [[package]]
38
38
  name = "click"
39
39
  version = "8.2.1"
40
- source = { registry = "https://pypi.org/simple/" }
40
+ source = { registry = "https://pypi.org/simple" }
41
41
  dependencies = [
42
42
  { name = "colorama", marker = "sys_platform == 'win32'" },
43
43
  ]
@@ -49,7 +49,7 @@ wheels = [
49
49
  [[package]]
50
50
  name = "colorama"
51
51
  version = "0.4.6"
52
- source = { registry = "https://pypi.org/simple/" }
52
+ source = { registry = "https://pypi.org/simple" }
53
53
  sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697, upload-time = "2022-10-25T02:36:22.414Z" }
54
54
  wheels = [
55
55
  { url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" },
@@ -58,7 +58,7 @@ wheels = [
58
58
  [[package]]
59
59
  name = "coverage"
60
60
  version = "7.10.1"
61
- source = { registry = "https://pypi.org/simple/" }
61
+ source = { registry = "https://pypi.org/simple" }
62
62
  sdist = { url = "https://files.pythonhosted.org/packages/87/0e/66dbd4c6a7f0758a8d18044c048779ba21fb94856e1edcf764bd5403e710/coverage-7.10.1.tar.gz", hash = "sha256:ae2b4856f29ddfe827106794f3589949a57da6f0d38ab01e24ec35107979ba57", size = 819938, upload-time = "2025-07-27T14:13:39.045Z" }
63
63
  wheels = [
64
64
  { url = "https://files.pythonhosted.org/packages/20/8e/ef088112bd1b26e2aa931ee186992b3e42c222c64f33e381432c8ee52aae/coverage-7.10.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:b45e2f9d5b0b5c1977cb4feb5f594be60eb121106f8900348e29331f553a726f", size = 214747, upload-time = "2025-07-27T14:11:18.217Z" },
@@ -138,7 +138,7 @@ toml = [
138
138
  [[package]]
139
139
  name = "docutils"
140
140
  version = "0.22"
141
- source = { registry = "https://pypi.org/simple/" }
141
+ source = { registry = "https://pypi.org/simple" }
142
142
  sdist = { url = "https://files.pythonhosted.org/packages/e9/86/5b41c32ecedcfdb4c77b28b6cb14234f252075f8cdb254531727a35547dd/docutils-0.22.tar.gz", hash = "sha256:ba9d57750e92331ebe7c08a1bbf7a7f8143b86c476acd51528b042216a6aad0f", size = 2277984, upload-time = "2025-07-29T15:20:31.06Z" }
143
143
  wheels = [
144
144
  { url = "https://files.pythonhosted.org/packages/44/57/8db39bc5f98f042e0153b1de9fb88e1a409a33cda4dd7f723c2ed71e01f6/docutils-0.22-py3-none-any.whl", hash = "sha256:4ed966a0e96a0477d852f7af31bdcb3adc049fbb35ccba358c2ea8a03287615e", size = 630709, upload-time = "2025-07-29T15:20:28.335Z" },
@@ -147,7 +147,7 @@ wheels = [
147
147
  [[package]]
148
148
  name = "fastapi"
149
149
  version = "0.116.1"
150
- source = { registry = "https://pypi.org/simple/" }
150
+ source = { registry = "https://pypi.org/simple" }
151
151
  dependencies = [
152
152
  { name = "pydantic" },
153
153
  { name = "starlette" },
@@ -160,7 +160,7 @@ wheels = [
160
160
 
161
161
  [[package]]
162
162
  name = "fastapi-testing"
163
- version = "0.3.0"
163
+ version = "0.3.1"
164
164
  source = { editable = "." }
165
165
  dependencies = [
166
166
  { name = "fastapi" },
@@ -178,6 +178,7 @@ dev = [
178
178
  { name = "pytest-asyncio" },
179
179
  { name = "pytest-cov" },
180
180
  { name = "restructuredtext-lint" },
181
+ { name = "ruff" },
181
182
  ]
182
183
 
183
184
  [package.metadata]
@@ -197,12 +198,13 @@ dev = [
197
198
  { name = "pytest-asyncio", specifier = ">=0.25.2" },
198
199
  { name = "pytest-cov", specifier = ">=6.0.0" },
199
200
  { name = "restructuredtext-lint", specifier = ">=1.4.0" },
201
+ { name = "ruff", specifier = ">=0.8.0" },
200
202
  ]
201
203
 
202
204
  [[package]]
203
205
  name = "h11"
204
206
  version = "0.16.0"
205
- source = { registry = "https://pypi.org/simple/" }
207
+ source = { registry = "https://pypi.org/simple" }
206
208
  sdist = { url = "https://files.pythonhosted.org/packages/01/ee/02a2c011bdab74c6fb3c75474d40b3052059d95df7e73351460c8588d963/h11-0.16.0.tar.gz", hash = "sha256:4e35b956cf45792e4caa5885e69fba00bdbc6ffafbfa020300e549b208ee5ff1", size = 101250, upload-time = "2025-04-24T03:35:25.427Z" }
207
209
  wheels = [
208
210
  { url = "https://files.pythonhosted.org/packages/04/4b/29cac41a4d98d144bf5f6d33995617b185d14b22401f75ca86f384e87ff1/h11-0.16.0-py3-none-any.whl", hash = "sha256:63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86", size = 37515, upload-time = "2025-04-24T03:35:24.344Z" },
@@ -211,7 +213,7 @@ wheels = [
211
213
  [[package]]
212
214
  name = "h2"
213
215
  version = "4.2.0"
214
- source = { registry = "https://pypi.org/simple/" }
216
+ source = { registry = "https://pypi.org/simple" }
215
217
  dependencies = [
216
218
  { name = "hpack" },
217
219
  { name = "hyperframe" },
@@ -224,7 +226,7 @@ wheels = [
224
226
  [[package]]
225
227
  name = "hpack"
226
228
  version = "4.1.0"
227
- source = { registry = "https://pypi.org/simple/" }
229
+ source = { registry = "https://pypi.org/simple" }
228
230
  sdist = { url = "https://files.pythonhosted.org/packages/2c/48/71de9ed269fdae9c8057e5a4c0aa7402e8bb16f2c6e90b3aa53327b113f8/hpack-4.1.0.tar.gz", hash = "sha256:ec5eca154f7056aa06f196a557655c5b009b382873ac8d1e66e79e87535f1dca", size = 51276, upload-time = "2025-01-22T21:44:58.347Z" }
229
231
  wheels = [
230
232
  { url = "https://files.pythonhosted.org/packages/07/c6/80c95b1b2b94682a72cbdbfb85b81ae2daffa4291fbfa1b1464502ede10d/hpack-4.1.0-py3-none-any.whl", hash = "sha256:157ac792668d995c657d93111f46b4535ed114f0c9c8d672271bbec7eae1b496", size = 34357, upload-time = "2025-01-22T21:44:56.92Z" },
@@ -233,7 +235,7 @@ wheels = [
233
235
  [[package]]
234
236
  name = "httpcore"
235
237
  version = "1.0.9"
236
- source = { registry = "https://pypi.org/simple/" }
238
+ source = { registry = "https://pypi.org/simple" }
237
239
  dependencies = [
238
240
  { name = "certifi" },
239
241
  { name = "h11" },
@@ -246,7 +248,7 @@ wheels = [
246
248
  [[package]]
247
249
  name = "httpx"
248
250
  version = "0.28.1"
249
- source = { registry = "https://pypi.org/simple/" }
251
+ source = { registry = "https://pypi.org/simple" }
250
252
  dependencies = [
251
253
  { name = "anyio" },
252
254
  { name = "certifi" },
@@ -266,7 +268,7 @@ http2 = [
266
268
  [[package]]
267
269
  name = "hyperframe"
268
270
  version = "6.1.0"
269
- source = { registry = "https://pypi.org/simple/" }
271
+ source = { registry = "https://pypi.org/simple" }
270
272
  sdist = { url = "https://files.pythonhosted.org/packages/02/e7/94f8232d4a74cc99514c13a9f995811485a6903d48e5d952771ef6322e30/hyperframe-6.1.0.tar.gz", hash = "sha256:f630908a00854a7adeabd6382b43923a4c4cd4b821fcb527e6ab9e15382a3b08", size = 26566, upload-time = "2025-01-22T21:41:49.302Z" }
271
273
  wheels = [
272
274
  { url = "https://files.pythonhosted.org/packages/48/30/47d0bf6072f7252e6521f3447ccfa40b421b6824517f82854703d0f5a98b/hyperframe-6.1.0-py3-none-any.whl", hash = "sha256:b03380493a519fce58ea5af42e4a42317bf9bd425596f7a0835ffce80f1a42e5", size = 13007, upload-time = "2025-01-22T21:41:47.295Z" },
@@ -275,7 +277,7 @@ wheels = [
275
277
  [[package]]
276
278
  name = "idna"
277
279
  version = "3.10"
278
- source = { registry = "https://pypi.org/simple/" }
280
+ source = { registry = "https://pypi.org/simple" }
279
281
  sdist = { url = "https://files.pythonhosted.org/packages/f1/70/7703c29685631f5a7590aa73f1f1d3fa9a380e654b86af429e0934a32f7d/idna-3.10.tar.gz", hash = "sha256:12f65c9b470abda6dc35cf8e63cc574b1c52b11df2c86030af0ac09b01b13ea9", size = 190490, upload-time = "2024-09-15T18:07:39.745Z" }
280
282
  wheels = [
281
283
  { url = "https://files.pythonhosted.org/packages/76/c6/c88e154df9c4e1a2a66ccf0005a88dfb2650c1dffb6f5ce603dfbd452ce3/idna-3.10-py3-none-any.whl", hash = "sha256:946d195a0d259cbba61165e88e65941f16e9b36ea6ddb97f00452bae8b1287d3", size = 70442, upload-time = "2024-09-15T18:07:37.964Z" },
@@ -284,7 +286,7 @@ wheels = [
284
286
  [[package]]
285
287
  name = "iniconfig"
286
288
  version = "2.1.0"
287
- source = { registry = "https://pypi.org/simple/" }
289
+ source = { registry = "https://pypi.org/simple" }
288
290
  sdist = { url = "https://files.pythonhosted.org/packages/f2/97/ebf4da567aa6827c909642694d71c9fcf53e5b504f2d96afea02718862f3/iniconfig-2.1.0.tar.gz", hash = "sha256:3abbd2e30b36733fee78f9c7f7308f2d0050e88f0087fd25c2645f63c773e1c7", size = 4793, upload-time = "2025-03-19T20:09:59.721Z" }
289
291
  wheels = [
290
292
  { url = "https://files.pythonhosted.org/packages/2c/e1/e6716421ea10d38022b952c159d5161ca1193197fb744506875fbb87ea7b/iniconfig-2.1.0-py3-none-any.whl", hash = "sha256:9deba5723312380e77435581c6bf4935c94cbfab9b1ed33ef8d238ea168eb760", size = 6050, upload-time = "2025-03-19T20:10:01.071Z" },
@@ -293,7 +295,7 @@ wheels = [
293
295
  [[package]]
294
296
  name = "packaging"
295
297
  version = "25.0"
296
- source = { registry = "https://pypi.org/simple/" }
298
+ source = { registry = "https://pypi.org/simple" }
297
299
  sdist = { url = "https://files.pythonhosted.org/packages/a1/d4/1fc4078c65507b51b96ca8f8c3ba19e6a61c8253c72794544580a7b6c24d/packaging-25.0.tar.gz", hash = "sha256:d443872c98d677bf60f6a1f2f8c1cb748e8fe762d2bf9d3148b5599295b0fc4f", size = 165727, upload-time = "2025-04-19T11:48:59.673Z" }
298
300
  wheels = [
299
301
  { url = "https://files.pythonhosted.org/packages/20/12/38679034af332785aac8774540895e234f4d07f7545804097de4b666afd8/packaging-25.0-py3-none-any.whl", hash = "sha256:29572ef2b1f17581046b3a2227d5c611fb25ec70ca1ba8554b24b0e69331a484", size = 66469, upload-time = "2025-04-19T11:48:57.875Z" },
@@ -302,7 +304,7 @@ wheels = [
302
304
  [[package]]
303
305
  name = "pluggy"
304
306
  version = "1.6.0"
305
- source = { registry = "https://pypi.org/simple/" }
307
+ source = { registry = "https://pypi.org/simple" }
306
308
  sdist = { url = "https://files.pythonhosted.org/packages/f9/e2/3e91f31a7d2b083fe6ef3fa267035b518369d9511ffab804f839851d2779/pluggy-1.6.0.tar.gz", hash = "sha256:7dcc130b76258d33b90f61b658791dede3486c3e6bfb003ee5c9bfb396dd22f3", size = 69412, upload-time = "2025-05-15T12:30:07.975Z" }
307
309
  wheels = [
308
310
  { url = "https://files.pythonhosted.org/packages/54/20/4d324d65cc6d9205fabedc306948156824eb9f0ee1633355a8f7ec5c66bf/pluggy-1.6.0-py3-none-any.whl", hash = "sha256:e920276dd6813095e9377c0bc5566d94c932c33b27a3e3945d8389c374dd4746", size = 20538, upload-time = "2025-05-15T12:30:06.134Z" },
@@ -311,7 +313,7 @@ wheels = [
311
313
  [[package]]
312
314
  name = "pydantic"
313
315
  version = "2.11.7"
314
- source = { registry = "https://pypi.org/simple/" }
316
+ source = { registry = "https://pypi.org/simple" }
315
317
  dependencies = [
316
318
  { name = "annotated-types" },
317
319
  { name = "pydantic-core" },
@@ -326,7 +328,7 @@ wheels = [
326
328
  [[package]]
327
329
  name = "pydantic-core"
328
330
  version = "2.33.2"
329
- source = { registry = "https://pypi.org/simple/" }
331
+ source = { registry = "https://pypi.org/simple" }
330
332
  dependencies = [
331
333
  { name = "typing-extensions" },
332
334
  ]
@@ -391,7 +393,7 @@ wheels = [
391
393
  [[package]]
392
394
  name = "pygments"
393
395
  version = "2.19.2"
394
- source = { registry = "https://pypi.org/simple/" }
396
+ source = { registry = "https://pypi.org/simple" }
395
397
  sdist = { url = "https://files.pythonhosted.org/packages/b0/77/a5b8c569bf593b0140bde72ea885a803b82086995367bf2037de0159d924/pygments-2.19.2.tar.gz", hash = "sha256:636cb2477cec7f8952536970bc533bc43743542f70392ae026374600add5b887", size = 4968631, upload-time = "2025-06-21T13:39:12.283Z" }
396
398
  wheels = [
397
399
  { url = "https://files.pythonhosted.org/packages/c7/21/705964c7812476f378728bdf590ca4b771ec72385c533964653c68e86bdc/pygments-2.19.2-py3-none-any.whl", hash = "sha256:86540386c03d588bb81d44bc3928634ff26449851e99741617ecb9037ee5ec0b", size = 1225217, upload-time = "2025-06-21T13:39:07.939Z" },
@@ -400,7 +402,7 @@ wheels = [
400
402
  [[package]]
401
403
  name = "pytest"
402
404
  version = "8.4.1"
403
- source = { registry = "https://pypi.org/simple/" }
405
+ source = { registry = "https://pypi.org/simple" }
404
406
  dependencies = [
405
407
  { name = "colorama", marker = "sys_platform == 'win32'" },
406
408
  { name = "iniconfig" },
@@ -416,7 +418,7 @@ wheels = [
416
418
  [[package]]
417
419
  name = "pytest-asyncio"
418
420
  version = "1.1.0"
419
- source = { registry = "https://pypi.org/simple/" }
421
+ source = { registry = "https://pypi.org/simple" }
420
422
  dependencies = [
421
423
  { name = "pytest" },
422
424
  ]
@@ -428,7 +430,7 @@ wheels = [
428
430
  [[package]]
429
431
  name = "pytest-cov"
430
432
  version = "6.2.1"
431
- source = { registry = "https://pypi.org/simple/" }
433
+ source = { registry = "https://pypi.org/simple" }
432
434
  dependencies = [
433
435
  { name = "coverage", extra = ["toml"] },
434
436
  { name = "pluggy" },
@@ -442,16 +444,41 @@ wheels = [
442
444
  [[package]]
443
445
  name = "restructuredtext-lint"
444
446
  version = "1.4.0"
445
- source = { registry = "https://pypi.org/simple/" }
447
+ source = { registry = "https://pypi.org/simple" }
446
448
  dependencies = [
447
449
  { name = "docutils" },
448
450
  ]
449
451
  sdist = { url = "https://files.pythonhosted.org/packages/48/9c/6d8035cafa2d2d314f34e6cd9313a299de095b26e96f1c7312878f988eec/restructuredtext_lint-1.4.0.tar.gz", hash = "sha256:1b235c0c922341ab6c530390892eb9e92f90b9b75046063e047cacfb0f050c45", size = 16723, upload-time = "2022-02-24T05:51:10.907Z" }
450
452
 
453
+ [[package]]
454
+ name = "ruff"
455
+ version = "0.12.7"
456
+ source = { registry = "https://pypi.org/simple" }
457
+ sdist = { url = "https://files.pythonhosted.org/packages/a1/81/0bd3594fa0f690466e41bd033bdcdf86cba8288345ac77ad4afbe5ec743a/ruff-0.12.7.tar.gz", hash = "sha256:1fc3193f238bc2d7968772c82831a4ff69252f673be371fb49663f0068b7ec71", size = 5197814, upload-time = "2025-07-29T22:32:35.877Z" }
458
+ wheels = [
459
+ { url = "https://files.pythonhosted.org/packages/e1/d2/6cb35e9c85e7a91e8d22ab32ae07ac39cc34a71f1009a6f9e4a2a019e602/ruff-0.12.7-py3-none-linux_armv6l.whl", hash = "sha256:76e4f31529899b8c434c3c1dede98c4483b89590e15fb49f2d46183801565303", size = 11852189, upload-time = "2025-07-29T22:31:41.281Z" },
460
+ { url = "https://files.pythonhosted.org/packages/63/5b/a4136b9921aa84638f1a6be7fb086f8cad0fde538ba76bda3682f2599a2f/ruff-0.12.7-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:789b7a03e72507c54fb3ba6209e4bb36517b90f1a3569ea17084e3fd295500fb", size = 12519389, upload-time = "2025-07-29T22:31:54.265Z" },
461
+ { url = "https://files.pythonhosted.org/packages/a8/c9/3e24a8472484269b6b1821794141f879c54645a111ded4b6f58f9ab0705f/ruff-0.12.7-py3-none-macosx_11_0_arm64.whl", hash = "sha256:2e1c2a3b8626339bb6369116e7030a4cf194ea48f49b64bb505732a7fce4f4e3", size = 11743384, upload-time = "2025-07-29T22:31:59.575Z" },
462
+ { url = "https://files.pythonhosted.org/packages/26/7c/458dd25deeb3452c43eaee853c0b17a1e84169f8021a26d500ead77964fd/ruff-0.12.7-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:32dec41817623d388e645612ec70d5757a6d9c035f3744a52c7b195a57e03860", size = 11943759, upload-time = "2025-07-29T22:32:01.95Z" },
463
+ { url = "https://files.pythonhosted.org/packages/7f/8b/658798472ef260ca050e400ab96ef7e85c366c39cf3dfbef4d0a46a528b6/ruff-0.12.7-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:47ef751f722053a5df5fa48d412dbb54d41ab9b17875c6840a58ec63ff0c247c", size = 11654028, upload-time = "2025-07-29T22:32:04.367Z" },
464
+ { url = "https://files.pythonhosted.org/packages/a8/86/9c2336f13b2a3326d06d39178fd3448dcc7025f82514d1b15816fe42bfe8/ruff-0.12.7-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a828a5fc25a3efd3e1ff7b241fd392686c9386f20e5ac90aa9234a5faa12c423", size = 13225209, upload-time = "2025-07-29T22:32:06.952Z" },
465
+ { url = "https://files.pythonhosted.org/packages/76/69/df73f65f53d6c463b19b6b312fd2391dc36425d926ec237a7ed028a90fc1/ruff-0.12.7-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:5726f59b171111fa6a69d82aef48f00b56598b03a22f0f4170664ff4d8298efb", size = 14182353, upload-time = "2025-07-29T22:32:10.053Z" },
466
+ { url = "https://files.pythonhosted.org/packages/58/1e/de6cda406d99fea84b66811c189b5ea139814b98125b052424b55d28a41c/ruff-0.12.7-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:74e6f5c04c4dd4aba223f4fe6e7104f79e0eebf7d307e4f9b18c18362124bccd", size = 13631555, upload-time = "2025-07-29T22:32:12.644Z" },
467
+ { url = "https://files.pythonhosted.org/packages/6f/ae/625d46d5164a6cc9261945a5e89df24457dc8262539ace3ac36c40f0b51e/ruff-0.12.7-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:5d0bfe4e77fba61bf2ccadf8cf005d6133e3ce08793bbe870dd1c734f2699a3e", size = 12667556, upload-time = "2025-07-29T22:32:15.312Z" },
468
+ { url = "https://files.pythonhosted.org/packages/55/bf/9cb1ea5e3066779e42ade8d0cd3d3b0582a5720a814ae1586f85014656b6/ruff-0.12.7-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:06bfb01e1623bf7f59ea749a841da56f8f653d641bfd046edee32ede7ff6c606", size = 12939784, upload-time = "2025-07-29T22:32:17.69Z" },
469
+ { url = "https://files.pythonhosted.org/packages/55/7f/7ead2663be5627c04be83754c4f3096603bf5e99ed856c7cd29618c691bd/ruff-0.12.7-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:e41df94a957d50083fd09b916d6e89e497246698c3f3d5c681c8b3e7b9bb4ac8", size = 11771356, upload-time = "2025-07-29T22:32:20.134Z" },
470
+ { url = "https://files.pythonhosted.org/packages/17/40/a95352ea16edf78cd3a938085dccc55df692a4d8ba1b3af7accbe2c806b0/ruff-0.12.7-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:4000623300563c709458d0ce170c3d0d788c23a058912f28bbadc6f905d67afa", size = 11612124, upload-time = "2025-07-29T22:32:22.645Z" },
471
+ { url = "https://files.pythonhosted.org/packages/4d/74/633b04871c669e23b8917877e812376827c06df866e1677f15abfadc95cb/ruff-0.12.7-py3-none-musllinux_1_2_i686.whl", hash = "sha256:69ffe0e5f9b2cf2b8e289a3f8945b402a1b19eff24ec389f45f23c42a3dd6fb5", size = 12479945, upload-time = "2025-07-29T22:32:24.765Z" },
472
+ { url = "https://files.pythonhosted.org/packages/be/34/c3ef2d7799c9778b835a76189c6f53c179d3bdebc8c65288c29032e03613/ruff-0.12.7-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:a07a5c8ffa2611a52732bdc67bf88e243abd84fe2d7f6daef3826b59abbfeda4", size = 12998677, upload-time = "2025-07-29T22:32:27.022Z" },
473
+ { url = "https://files.pythonhosted.org/packages/77/ab/aca2e756ad7b09b3d662a41773f3edcbd262872a4fc81f920dc1ffa44541/ruff-0.12.7-py3-none-win32.whl", hash = "sha256:c928f1b2ec59fb77dfdf70e0419408898b63998789cc98197e15f560b9e77f77", size = 11756687, upload-time = "2025-07-29T22:32:29.381Z" },
474
+ { url = "https://files.pythonhosted.org/packages/b4/71/26d45a5042bc71db22ddd8252ca9d01e9ca454f230e2996bb04f16d72799/ruff-0.12.7-py3-none-win_amd64.whl", hash = "sha256:9c18f3d707ee9edf89da76131956aba1270c6348bfee8f6c647de841eac7194f", size = 12912365, upload-time = "2025-07-29T22:32:31.517Z" },
475
+ { url = "https://files.pythonhosted.org/packages/4c/9b/0b8aa09817b63e78d94b4977f18b1fcaead3165a5ee49251c5d5c245bb2d/ruff-0.12.7-py3-none-win_arm64.whl", hash = "sha256:dfce05101dbd11833a0776716d5d1578641b7fddb537fe7fa956ab85d1769b69", size = 11982083, upload-time = "2025-07-29T22:32:33.881Z" },
476
+ ]
477
+
451
478
  [[package]]
452
479
  name = "sniffio"
453
480
  version = "1.3.1"
454
- source = { registry = "https://pypi.org/simple/" }
481
+ source = { registry = "https://pypi.org/simple" }
455
482
  sdist = { url = "https://files.pythonhosted.org/packages/a2/87/a6771e1546d97e7e041b6ae58d80074f81b7d5121207425c964ddf5cfdbd/sniffio-1.3.1.tar.gz", hash = "sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc", size = 20372, upload-time = "2024-02-25T23:20:04.057Z" }
456
483
  wheels = [
457
484
  { url = "https://files.pythonhosted.org/packages/e9/44/75a9c9421471a6c4805dbf2356f7c181a29c1879239abab1ea2cc8f38b40/sniffio-1.3.1-py3-none-any.whl", hash = "sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2", size = 10235, upload-time = "2024-02-25T23:20:01.196Z" },
@@ -460,7 +487,7 @@ wheels = [
460
487
  [[package]]
461
488
  name = "starlette"
462
489
  version = "0.47.2"
463
- source = { registry = "https://pypi.org/simple/" }
490
+ source = { registry = "https://pypi.org/simple" }
464
491
  dependencies = [
465
492
  { name = "anyio" },
466
493
  { name = "typing-extensions", marker = "python_full_version < '3.13'" },
@@ -473,7 +500,7 @@ wheels = [
473
500
  [[package]]
474
501
  name = "tomli"
475
502
  version = "2.2.1"
476
- source = { registry = "https://pypi.org/simple/" }
503
+ source = { registry = "https://pypi.org/simple" }
477
504
  sdist = { url = "https://files.pythonhosted.org/packages/18/87/302344fed471e44a87289cf4967697d07e532f2421fdaf868a303cbae4ff/tomli-2.2.1.tar.gz", hash = "sha256:cd45e1dc79c835ce60f7404ec8119f2eb06d38b1deba146f07ced3bbc44505ff", size = 17175, upload-time = "2024-11-27T22:38:36.873Z" }
478
505
  wheels = [
479
506
  { url = "https://files.pythonhosted.org/packages/43/ca/75707e6efa2b37c77dadb324ae7d9571cb424e61ea73fad7c56c2d14527f/tomli-2.2.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:678e4fa69e4575eb77d103de3df8a895e1591b48e740211bd1067378c69e8249", size = 131077, upload-time = "2024-11-27T22:37:54.956Z" },
@@ -512,7 +539,7 @@ wheels = [
512
539
  [[package]]
513
540
  name = "typing-extensions"
514
541
  version = "4.14.1"
515
- source = { registry = "https://pypi.org/simple/" }
542
+ source = { registry = "https://pypi.org/simple" }
516
543
  sdist = { url = "https://files.pythonhosted.org/packages/98/5a/da40306b885cc8c09109dc2e1abd358d5684b1425678151cdaed4731c822/typing_extensions-4.14.1.tar.gz", hash = "sha256:38b39f4aeeab64884ce9f74c94263ef78f3c22467c8724005483154c26648d36", size = 107673, upload-time = "2025-07-04T13:28:34.16Z" }
517
544
  wheels = [
518
545
  { url = "https://files.pythonhosted.org/packages/b5/00/d631e67a838026495268c2f6884f3711a15a9a2a96cd244fdaea53b823fb/typing_extensions-4.14.1-py3-none-any.whl", hash = "sha256:d1e1e3b58374dc93031d6eda2420a48ea44a36c2b4766a4fdeb3710755731d76", size = 43906, upload-time = "2025-07-04T13:28:32.743Z" },
@@ -521,7 +548,7 @@ wheels = [
521
548
  [[package]]
522
549
  name = "typing-inspection"
523
550
  version = "0.4.1"
524
- source = { registry = "https://pypi.org/simple/" }
551
+ source = { registry = "https://pypi.org/simple" }
525
552
  dependencies = [
526
553
  { name = "typing-extensions" },
527
554
  ]
@@ -533,7 +560,7 @@ wheels = [
533
560
  [[package]]
534
561
  name = "uvicorn"
535
562
  version = "0.35.0"
536
- source = { registry = "https://pypi.org/simple/" }
563
+ source = { registry = "https://pypi.org/simple" }
537
564
  dependencies = [
538
565
  { name = "click" },
539
566
  { name = "h11" },
@@ -546,7 +573,7 @@ wheels = [
546
573
  [[package]]
547
574
  name = "websockets"
548
575
  version = "15.0.1"
549
- source = { registry = "https://pypi.org/simple/" }
576
+ source = { registry = "https://pypi.org/simple" }
550
577
  sdist = { url = "https://files.pythonhosted.org/packages/21/e6/26d09fab466b7ca9c7737474c52be4f76a40301b08362eb2dbc19dcc16c1/websockets-15.0.1.tar.gz", hash = "sha256:82544de02076bafba038ce055ee6412d68da13ab47f0c60cab827346de828dee", size = 177016, upload-time = "2025-03-05T20:03:41.606Z" }
551
578
  wheels = [
552
579
  { url = "https://files.pythonhosted.org/packages/9f/32/18fcd5919c293a398db67443acd33fde142f283853076049824fc58e6f75/websockets-15.0.1-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:823c248b690b2fd9303ba00c4f66cd5e2d8c3ba4aa968b2779be9532a4dad431", size = 175423, upload-time = "2025-03-05T20:01:56.276Z" },
File without changes
@@ -1,27 +1,27 @@
1
1
  from fastapi_testing.async_fastapi_testing import (
2
+ AsyncTestClient,
3
+ AsyncTestResponse,
4
+ AsyncTestServer,
2
5
  Config,
3
- global_config,
4
6
  InvalidResponseTypeError,
5
7
  PortGenerator,
6
8
  UvicornTestServer,
7
- AsyncTestServer,
8
- AsyncTestClient,
9
- AsyncTestResponse,
10
9
  WebSocketConfig,
11
10
  WebSocketHelper,
12
11
  create_test_server,
12
+ global_config,
13
13
  )
14
14
 
15
15
  __all__ = [
16
+ "AsyncTestClient",
17
+ "AsyncTestResponse",
18
+ "AsyncTestServer",
16
19
  "Config",
17
- "global_config",
18
20
  "InvalidResponseTypeError",
19
21
  "PortGenerator",
20
22
  "UvicornTestServer",
21
- "AsyncTestServer",
22
- "AsyncTestClient",
23
- "AsyncTestResponse",
24
23
  "WebSocketConfig",
25
24
  "WebSocketHelper",
26
25
  "create_test_server",
26
+ "global_config",
27
27
  ]