Skip to content

Commit

Permalink
✅ Refactor tests for duplicate operation ID generation for compatibil…
Browse files Browse the repository at this point in the history
…ity with other tools running the FastAPI test suite (#10876)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
  • Loading branch information
3 people committed Jan 13, 2024
1 parent 61a08d0 commit f18eadb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tests/test_generate_unique_id_function.py
Expand Up @@ -1626,6 +1626,9 @@ def post_third(item1: Item):
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
client.get("/openapi.json")
assert len(w) == 2
assert issubclass(w[-1].category, UserWarning)
assert "Duplicate Operation ID" in str(w[-1].message)
assert len(w) >= 2
duplicate_warnings = [
warning for warning in w if issubclass(warning.category, UserWarning)
]
assert len(duplicate_warnings) > 0
assert "Duplicate Operation ID" in str(duplicate_warnings[0].message)

0 comments on commit f18eadb

Please sign in to comment.