summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaselIT <cfederico87@gmail.com>2021-12-01 22:11:36 +0100
committerFederico Caselli <cfederico87@gmail.com>2021-12-31 18:12:38 +0000
commit5fce5dbd53cd23c972e82f8cba91a3b4624e523b (patch)
tree4e6b8a5f4c7be1cb770f269eae9fa99271ebec1e
parent270702253ecb78f7f3e3d920169ab160f8469904 (diff)
downloadalembic-5fce5dbd53cd23c972e82f8cba91a3b4624e523b.tar.gz
Provide useful error message in stub tests
Change-Id: I6d2662cb5c13d5438210aa001cbdb8c7eb876bb7
-rw-r--r--tests/test_stubs.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/tests/test_stubs.py b/tests/test_stubs.py
index efb1a9d..d1e286e 100644
--- a/tests/test_stubs.py
+++ b/tests/test_stubs.py
@@ -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)