浏览代码

Support False value for MockState attribute (#2173)

resolves #2172

Co-authored-by: Fred Lefévère-Laoide <Fred.Lefevere-Laoide@Taipy.io>
Fred Lefévère-Laoide 6 月之前
父节点
当前提交
94dcf55a6d
共有 2 个文件被更改,包括 5 次插入1 次删除
  1. 1 1
      taipy/gui/mock/mock_state.py
  2. 4 0
      tests/gui/mock/test_mock_state.py

+ 1 - 1
taipy/gui/mock/mock_state.py

@@ -37,7 +37,7 @@ class MockState(State):
         return self._gui
 
     def __getattribute__(self, name: str) -> t.Any:
-        if attr := t.cast(dict, super().__getattribute__(MockState.__VARS)).get(name):
+        if (attr := t.cast(dict, super().__getattribute__(MockState.__VARS)).get(name, None)) is not None:
             return attr
         try:
             return super().__getattribute__(name)

+ 4 - 0
tests/gui/mock/test_mock_state.py

@@ -100,3 +100,7 @@ def test_callback():
     ms = MockState(Gui(""), a=1)
     on_action(ms)
     assert ms.a == 2
+
+def test_false():
+    ms = MockState(Gui(""), a=False)
+    assert ms.a is False