Skip to content

Commit 29c19df

Browse files
authored
test: add coverage for __eq__ returning NotImplemented (#17)
Add tests verifying that Table.__eq__ and Transaction.__eq__ return NotImplemented when compared against incompatible types.
1 parent e0ca4b4 commit 29c19df

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

tests/unit/test_table.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,6 +1509,15 @@ def test_eq_with_non_table_returns_false(
15091509

15101510
assert result is False
15111511

1512+
def test_eq_returns_not_implemented_for_non_table(
1513+
self, make_table: "Callable[..., Table]"
1514+
) -> None:
1515+
table = make_table()
1516+
1517+
result = table.__eq__("string")
1518+
1519+
assert result is NotImplemented
1520+
15121521
def test_equal_relative_vs_absolute_path(
15131522
self, tmp_path: "Path", monkeypatch: "pytest.MonkeyPatch"
15141523
) -> None:

tests/unit/test_transaction.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,6 +1393,18 @@ def test_eq_with_non_transaction_returns_false(
13931393
finally:
13941394
tx.abort()
13951395

1396+
def test_eq_returns_not_implemented_for_non_transaction(
1397+
self, make_table: "Callable[..., Table]"
1398+
) -> None:
1399+
table = make_table()
1400+
1401+
tx = table.transaction()
1402+
try:
1403+
result = tx.__eq__("string")
1404+
assert result is NotImplemented
1405+
finally:
1406+
tx.abort()
1407+
13961408
def test_finalized_vs_active_not_equal(self, tmp_path: "Path") -> None:
13971409
path1 = tmp_path / "test1.jsonlt"
13981410
path2 = tmp_path / "test2.jsonlt"

0 commit comments

Comments
 (0)