✅ Simplify tests for code examples, one test file for multiple variants#1664
Merged
tiangolo merged 80 commits intofastapi:mainfrom Dec 24, 2025
Merged
✅ Simplify tests for code examples, one test file for multiple variants#1664tiangolo merged 80 commits intofastapi:mainfrom
tiangolo merged 80 commits intofastapi:mainfrom
Conversation
…d `docs_src.tutorial.connect.select.tutorial002*`
…src.tutorial.delete.tutorial002*`
…00X` (X: 1-4) to tests variants
…_delete_relationships.tutorial003*`
…_delete_relationships.tutorial004*`
…_delete_relationships.tutorial005*`
…lationships.tutorial001*`
…lationships.tutorial002*`
…src.tutorial.select.tutorial002*`
…src.tutorial.select.tutorial004*`
…src.tutorial.update.tutorial002*`
…src.tutorial.update.tutorial004*`
YuriiMotov
commented
Dec 3, 2025
|
|
||
|
|
||
| def test_run_tests(module: ModuleType): | ||
| test_path = Path(module.__file__).resolve().parent |
Member
Author
There was a problem hiding this comment.
This way we run all tests inside docs_src/tutorial/fastapi/app_testing/tutorial001 and its variants:
Details
print(result.stdout.decode("utf-8"))
docs_src/tutorial/fastapi/app_testing/tutorial001/test_extra_coverage.py ..... [ 27%]
docs_src/tutorial/fastapi/app_testing/tutorial001/test_main.py ....... [ 66%]
docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_001.py . [ 72%]
docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_002.py . [ 77%]
docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_003.py . [ 83%]
docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_004.py . [ 88%]
docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_005.py . [ 94%]
docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_006.py .
So, probably test_tutorial001_tests001.py ... test_tutorial001_tests006.py are redundant
tiangolo
approved these changes
Dec 24, 2025
Member
tiangolo
left a comment
There was a problem hiding this comment.
Amazing, thank you for this! 14K lines removed! 🎉 🔥
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There are no tests for variants of test_main_005 and test_main_006 in
docs_src/tutorial/fastapi/app_testing/tutorial001**.And I don't know how to add them as it seems there is no way to import fixture dynamically (so, we can only duplicate test files for each variant).
But actually we already run these tests as I explained in this comment. So, maybe we can remove all files in test_app_testing except
test_tutorial001_tests_main.py. Or leave it as it is