瀏覽代碼

Fix var name test (#1032)

Dinh Long Nguyen 1 年之前
父節點
當前提交
9d8b66379d
共有 1 個文件被更改,包括 8 次插入3 次删除
  1. 8 3
      tests/gui/gui_specific/test_gui.py

+ 8 - 3
tests/gui/gui_specific/test_gui.py

@@ -9,25 +9,30 @@
 # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 # specific language governing permissions and limitations under the License.
 
+import inspect
 import json
+from contextlib import nullcontext
 
 import pandas as pd
 import pytest
 
 from taipy.gui import Gui
-from taipy.gui.utils import _TaipyContent
+from taipy.gui.utils import _get_module_name_from_frame, _TaipyContent
 
 
 def test__get_real_var_name(gui: Gui):
     res = gui._get_real_var_name("")
+    frame = inspect.currentframe()
+    gui._set_frame(frame)
     assert isinstance(res, tuple)
     assert res[0] == ""
     assert res[1] == ""
 
     gui.run(run_server=False)
     with gui.get_flask_app().app_context():
-        with pytest.raises(NameError):
-            res = gui._get_real_var_name(f"{_TaipyContent.get_hash()}_var")
+        with gui._set_locals_context(_get_module_name_from_frame(frame)) if frame else nullcontext():
+            with pytest.raises(NameError):
+                res = gui._get_real_var_name(f"{_TaipyContent.get_hash()}_var")
 
 
 def test__get_user_instance(gui: Gui):