]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
✅ Refactor tests for duplicate operation ID generation for compatibility with other...
authorEmmett Butler <723615+emmettbutler@users.noreply.github.com>
Sat, 13 Jan 2024 15:10:26 +0000 (07:10 -0800)
committerGitHub <noreply@github.com>
Sat, 13 Jan 2024 15:10:26 +0000 (16:10 +0100)
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>
tests/test_generate_unique_id_function.py

index c5ef5182b73f786ad8d3e57a1927081b54b5a91e..5aeec66367a7c1a6f4ee4f37a751cd38fa795cb1 100644 (file)
@@ -1626,6 +1626,9 @@ def test_warn_duplicate_operation_id():
     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)