fastapi-testing 0.2.2__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.
@@ -0,0 +1,33 @@
1
+ [run]
2
+ source = src/fastapi_testing
3
+ omit =
4
+ */tests/*
5
+ */test_*
6
+ */__pycache__/*
7
+ */migrations/*
8
+ */.venv/*
9
+ */env/*
10
+ setup.py
11
+
12
+ [report]
13
+ exclude_lines =
14
+ pragma: no cover
15
+ def __repr__
16
+ if self.debug:
17
+ if settings.DEBUG
18
+ raise AssertionError
19
+ raise NotImplementedError
20
+ if 0:
21
+ if __name__ == .__main__.:
22
+ class .*\bProtocol\):
23
+ @(abc\.)?abstractmethod
24
+
25
+ show_missing = True
26
+ skip_covered = False
27
+ precision = 2
28
+
29
+ [html]
30
+ directory = htmlcov
31
+
32
+ [xml]
33
+ output = coverage.xml
@@ -0,0 +1,164 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
110
+ .pdm.toml
111
+ .pdm-python
112
+ .pdm-build/
113
+
114
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
115
+ __pypackages__/
116
+
117
+ # Celery stuff
118
+ celerybeat-schedule
119
+ celerybeat.pid
120
+
121
+ # SageMath parsed files
122
+ *.sage.py
123
+
124
+ # Environments
125
+ .env
126
+ .venv
127
+ env/
128
+ venv/
129
+ ENV/
130
+ env.bak/
131
+ venv.bak/
132
+
133
+ # Spyder project settings
134
+ .spyderproject
135
+ .spyproject
136
+
137
+ # Rope project settings
138
+ .ropeproject
139
+
140
+ # mkdocs documentation
141
+ /site
142
+
143
+ # mypy
144
+ .mypy_cache/
145
+ .dmypy.json
146
+ dmypy.json
147
+
148
+ # Pyre type checker
149
+ .pyre/
150
+
151
+ # pytype static type analyzer
152
+ .pytype/
153
+
154
+ # Cython debug symbols
155
+ cython_debug/
156
+
157
+ # PyCharm
158
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
159
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
160
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
161
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
162
+ .idea/
163
+
164
+
@@ -0,0 +1,32 @@
1
+ {
2
+ "terminal.integrated.env.osx": {
3
+ "PYTHONPATH": "${workspaceFolder}/src"
4
+ },
5
+ "terminal.integrated.env.linux": {
6
+ "PYTHONPATH": "${workspaceFolder}/src"
7
+ },
8
+ "terminal.integrated.env.windows": {
9
+ "PYTHONPATH": "${workspaceFolder}/src"
10
+ },
11
+ "python.envFile": "${workspaceFolder}/.env",
12
+ "python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",
13
+ "python.testing.pytestEnabled": true,
14
+ "python.testing.unittestEnabled": false,
15
+ "python.testing.pytestPath": "${workspaceFolder}/.venv/bin/pytest",
16
+ "python.testing.pytestArgs": [
17
+ "tests",
18
+ "-v",
19
+ "-s",
20
+ "--tb=short"
21
+ ],
22
+ "python.testing.unittestArgs": [
23
+ "-v",
24
+ "-s",
25
+ "./tests",
26
+ "-p",
27
+ "test_*.py"
28
+ ],
29
+ "python.analysis.extraPaths": [
30
+ "${workspaceFolder}/src"
31
+ ]
32
+ }
@@ -1,5 +1,42 @@
1
+ Metadata-Version: 2.4
2
+ Name: fastapi-testing
3
+ Version: 0.3.1
4
+ Summary: A lightweight, async-first testing framework for FastAPI applications
5
+ Project-URL: Homepage, https://github.com/descoped/fastapi-testing
6
+ Project-URL: Repository, https://github.com/descoped/fastapi-testing
7
+ Project-URL: Issues, https://github.com/descoped/fastapi-testing/issues
8
+ Author-email: Ove Ranheim <oranheim@gmail.com>
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: async,fastapi,integration-testing,pytest,test-framework,testing
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Framework :: FastAPI
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Classifier: Topic :: Software Development :: Testing
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: >=3.11
25
+ Requires-Dist: fastapi>=0.116.1
26
+ Requires-Dist: httpx[http2]>=0.28.1
27
+ Requires-Dist: starlette>=0.47.2
28
+ Requires-Dist: uvicorn>=0.35.0
29
+ Requires-Dist: websockets>=15.0.1
30
+ Description-Content-Type: text/markdown
31
+
1
32
  # FastAPI Testing
2
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
+
3
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.
4
41
 
5
42
  ## Features
@@ -14,6 +51,11 @@ A lightweight, async-first testing framework designed specifically for FastAPI a
14
51
 
15
52
  ## Installation
16
53
 
54
+ ```bash
55
+ uv add fastapi-testing
56
+ ```
57
+
58
+ Or with pip:
17
59
  ```bash
18
60
  pip install fastapi-testing
19
61
  ```
@@ -350,6 +392,38 @@ server = AsyncTestServer(
350
392
  4. Handle exceptions appropriately in your tests
351
393
  5. Use type hints to catch potential issues early
352
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
+
353
427
  ## Error Handling
354
428
 
355
429
  The framework provides clear error messages for common issues:
@@ -1,35 +1,11 @@
1
- Metadata-Version: 2.3
2
- Name: fastapi-testing
3
- Version: 0.2.2
4
- Summary: A lightweight, async-first testing framework for FastAPI applications
5
- License: MIT
6
- Keywords: fastapi,testing,async,pytest,integration-testing,test-framework
7
- Author: Ove Ranheim
8
- Author-email: oranheim@gmail.com
9
- Requires-Python: >=3.11,<4.0
10
- Classifier: Development Status :: 5 - Production/Stable
11
- Classifier: Framework :: FastAPI
12
- Classifier: Intended Audience :: Developers
13
- Classifier: License :: OSI Approved :: MIT License
14
- Classifier: Operating System :: OS Independent
15
- Classifier: Programming Language :: Python :: 3
16
- Classifier: Programming Language :: Python :: 3.11
17
- Classifier: Programming Language :: Python :: 3.12
18
- Classifier: Programming Language :: Python :: 3.13
19
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
- Classifier: Topic :: Software Development :: Testing
21
- Classifier: Typing :: Typed
22
- Requires-Dist: fastapi (>=0.115.0,<0.116.0)
23
- Requires-Dist: httpx[http2] (>=0.23.0,<0.28.0)
24
- Requires-Dist: starlette (>=0.45.0,<0.46.0)
25
- Requires-Dist: uvicorn (>=0.34.0,<0.35.0)
26
- Requires-Dist: websockets (>=15.0,<16.0)
27
- Project-URL: Homepage, https://github.com/descoped/fastapi-testing
28
- Project-URL: Repository, https://github.com/descoped/fastapi-testing
29
- Description-Content-Type: text/markdown
30
-
31
1
  # FastAPI Testing
32
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
+
33
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.
34
10
 
35
11
  ## Features
@@ -44,6 +20,11 @@ A lightweight, async-first testing framework designed specifically for FastAPI a
44
20
 
45
21
  ## Installation
46
22
 
23
+ ```bash
24
+ uv add fastapi-testing
25
+ ```
26
+
27
+ Or with pip:
47
28
  ```bash
48
29
  pip install fastapi-testing
49
30
  ```
@@ -380,6 +361,38 @@ server = AsyncTestServer(
380
361
  4. Handle exceptions appropriately in your tests
381
362
  5. Use type hints to catch potential issues early
382
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
+
383
396
  ## Error Handling
384
397
 
385
398
  The framework provides clear error messages for common issues:
@@ -398,4 +411,3 @@ The framework provides clear error messages for common issues:
398
411
  ## Contributing
399
412
 
400
413
  Contributions are welcome! Please feel free to submit a Pull Request.
401
-
@@ -0,0 +1,145 @@
1
+ [project]
2
+ name = "fastapi-testing"
3
+ version = "0.3.1"
4
+ description = "A lightweight, async-first testing framework for FastAPI applications"
5
+ authors = [
6
+ { name = "Ove Ranheim", email = "oranheim@gmail.com" }
7
+ ]
8
+ requires-python = ">=3.11"
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ keywords = ["fastapi", "testing", "async", "pytest", "integration-testing", "test-framework"]
12
+ classifiers = [
13
+ "Development Status :: 5 - Production/Stable",
14
+ "Intended Audience :: Developers",
15
+ "Operating System :: OS Independent",
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: 3.11",
18
+ "Programming Language :: Python :: 3.12",
19
+ "Programming Language :: Python :: 3.13",
20
+ "Framework :: FastAPI",
21
+ "Topic :: Software Development :: Testing",
22
+ "Topic :: Software Development :: Libraries :: Python Modules",
23
+ "Typing :: Typed",
24
+ "License :: OSI Approved :: MIT License",
25
+ ]
26
+ dependencies = [
27
+ "fastapi>=0.116.1",
28
+ "starlette>=0.47.2",
29
+ "uvicorn>=0.35.0",
30
+ "httpx[http2]>=0.28.1",
31
+ "websockets>=15.0.1",
32
+ ]
33
+
34
+ [dependency-groups]
35
+ dev = [
36
+ "pytest>=8.3.0",
37
+ "pytest-asyncio>=0.25.2",
38
+ "pytest-cov>=6.0.0",
39
+ "pydantic>=2.10.6",
40
+ "ruff>=0.8.0",
41
+ "restructuredtext-lint>=1.4.0",
42
+ "pygments>=2.19.1",
43
+ ]
44
+
45
+ [build-system]
46
+ requires = ["hatchling>=1.26.3"]
47
+ build-backend = "hatchling.build"
48
+
49
+ [tool.hatch.build.targets.wheel]
50
+ packages = ["src/fastapi_testing"]
51
+
52
+ [tool.hatch.build]
53
+ exclude = [
54
+ "docs/*",
55
+ "examples/*",
56
+ "tests/*",
57
+ ".github/*",
58
+ "*.gif",
59
+ "*.png",
60
+ "dist/*",
61
+ "build/*",
62
+ ".pytest_cache",
63
+ "__pycache__",
64
+ "*.pyc"
65
+ ]
66
+
67
+ [project.urls]
68
+ Homepage = "https://github.com/descoped/fastapi-testing"
69
+ Repository = "https://github.com/descoped/fastapi-testing"
70
+ Issues = "https://github.com/descoped/fastapi-testing/issues"
71
+
72
+ [[tool.uv.index]]
73
+ name = "pypi"
74
+ url = "https://pypi.org/simple/"
75
+ publish-url = "https://upload.pypi.org/legacy/"
76
+
77
+ [[tool.uv.index]]
78
+ name = "testpypi"
79
+ url = "https://test.pypi.org/simple/"
80
+ publish-url = "https://test.pypi.org/legacy/"
81
+
82
+ [tool.pytest.ini_options]
83
+ testpaths = ["tests"]
84
+ python_files = ["test_*.py"]
85
+ asyncio_mode = "auto"
86
+ asyncio_default_fixture_loop_scope = "function"
87
+ markers = [
88
+ "asyncio: mark test as async",
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"