Skip to content

Commit 9689cdc

Browse files
committed
feat: add comprehensive test coverage and modern code quality tooling
- Add ruff as code formatter and linter with comprehensive configuration - Add efficient coverage tests to improve test reliability and CI performance - Modernize type annotations using Python 3.11+ syntax (list[T] vs List[T]) - Replace try/except blocks with contextlib.suppress where appropriate - Improve import organization and sorting consistency - Update all test files with consistent formatting and style - Configure ruff with project-specific rules and exclusions This adds new testing capabilities and modern tooling while improving overall code quality and maintainability.
1 parent 35b2603 commit 9689cdc

12 files changed

Lines changed: 459 additions & 206 deletions

pyproject.toml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ dev = [
3737
"pytest-asyncio>=0.25.2",
3838
"pytest-cov>=6.0.0",
3939
"pydantic>=2.10.6",
40+
"ruff>=0.8.0",
4041
"restructuredtext-lint>=1.4.0",
4142
"pygments>=2.19.1",
4243
]
@@ -86,3 +87,59 @@ asyncio_default_fixture_loop_scope = "function"
8687
markers = [
8788
"asyncio: mark test as async",
8889
]
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"

src/fastapi_testing/__init__.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
from fastapi_testing.async_fastapi_testing import (
2+
AsyncTestClient,
3+
AsyncTestResponse,
4+
AsyncTestServer,
25
Config,
3-
global_config,
46
InvalidResponseTypeError,
57
PortGenerator,
68
UvicornTestServer,
7-
AsyncTestServer,
8-
AsyncTestClient,
9-
AsyncTestResponse,
109
WebSocketConfig,
1110
WebSocketHelper,
1211
create_test_server,
12+
global_config,
1313
)
1414

1515
__all__ = [
16+
"AsyncTestClient",
17+
"AsyncTestResponse",
18+
"AsyncTestServer",
1619
"Config",
17-
"global_config",
1820
"InvalidResponseTypeError",
1921
"PortGenerator",
2022
"UvicornTestServer",
21-
"AsyncTestServer",
22-
"AsyncTestClient",
23-
"AsyncTestResponse",
2423
"WebSocketConfig",
2524
"WebSocketHelper",
2625
"create_test_server",
26+
"global_config",
2727
]

0 commit comments

Comments
 (0)