Skip to content

Commit 6d48005

Browse files
Add a test for binding merging.
1 parent 338d74c commit 6d48005

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/test_dom.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,39 @@ def test_validate():
4545
node.toggle_class("1")
4646

4747

48+
def test_inherited_bindings():
49+
"""Test if binding merging is done correctly when (not) inheriting bindings."""
50+
class A(DOMNode):
51+
BINDINGS = [("a", "a", "a")]
52+
53+
class B(A):
54+
BINDINGS = [("b", "b", "b")]
55+
56+
class C(B, inherit_bindings=False):
57+
BINDINGS = [("c", "c", "c")]
58+
59+
class D(C, inherit_bindings=False):
60+
pass
61+
62+
class E(D):
63+
BINDINGS = [("e", "e", "e")]
64+
65+
a = A()
66+
assert list(a._bindings.keys.keys()) == ["a"]
67+
68+
b = B()
69+
assert list(b._bindings.keys.keys()) == ["a", "b"]
70+
71+
c = C()
72+
assert list(c._bindings.keys.keys()) == ["c"]
73+
74+
d = D()
75+
assert not list(d._bindings.keys.keys())
76+
77+
e = E()
78+
assert list(e._bindings.keys.keys()) == ["e"]
79+
80+
4881
@pytest.fixture
4982
def search():
5083
"""

0 commit comments

Comments
 (0)