]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
Provide useful error message in stub tests
authorCaselIT <cfederico87@gmail.com>
Wed, 1 Dec 2021 21:11:36 +0000 (22:11 +0100)
committerFederico Caselli <cfederico87@gmail.com>
Fri, 31 Dec 2021 18:12:38 +0000 (18:12 +0000)
Change-Id: I6d2662cb5c13d5438210aa001cbdb8c7eb876bb7

tests/test_stubs.py

index efb1a9dfcd76fa815933630d2e8229372bca886f..d1e286ee8b3fb73bd43833fae08af82cacd97cd2 100644 (file)
@@ -1,3 +1,4 @@
+import difflib
 from pathlib import Path
 import subprocess
 import sys
@@ -31,11 +32,23 @@ class TestStubFiles(TestBase):
     def test_op_pyi(self):
         res = run_command("op")
         generated = res.stdout
-        expected = Path(alembic.__file__).parent / "op.pyi"
-        eq_(generated, expected.read_text())
+        file_path = Path(alembic.__file__).parent / "op.pyi"
+        expected = file_path.read_text()
+        eq_(generated, expected, compare(generated, expected))
 
     def test_context_pyi(self):
         res = run_command("context")
         generated = res.stdout
-        expected = Path(alembic.__file__).parent / "context.pyi"
-        eq_(generated, expected.read_text())
+        file_path = Path(alembic.__file__).parent / "context.pyi"
+        expected = file_path.read_text()
+        eq_(generated, expected, compare(generated, expected))
+
+
+def compare(actual: str, expected: str):
+    diff = difflib.unified_diff(
+        actual.splitlines(),
+        expected.splitlines(),
+        fromfile="generated",
+        tofile="expected",
+    )
+    return "\n".join(diff)